Eek out some file size

This commit is contained in:
Aaron Jensen 2015-08-22 11:03:38 -07:00
parent 01b9e772d8
commit 6437d98f73
2 changed files with 21 additions and 16 deletions

View File

@ -4,6 +4,7 @@ var webpack = require('webpack');
module.exports = function createWebpackConfig(_options) {
var config;
var options = _options || {};
var env = options.env || 'development';
config = {
context: options.context,
@ -11,8 +12,17 @@ module.exports = function createWebpackConfig(_options) {
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(env),
},
}),
],
node: {
process: false,
},
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
@ -35,6 +45,9 @@ module.exports = function createWebpackConfig(_options) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true,
warnings: false,
},
@ -42,15 +55,5 @@ module.exports = function createWebpackConfig(_options) {
);
}
if (options.env) {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(options.env),
},
})
);
}
return config;
};

View File

@ -43,13 +43,15 @@ describe('u.freeze', () => {
expect(Object.isFrozen(object.foo)).to.be.false;
});
it('does not freeze in production', () => {
process.env.NODE_ENV = 'production';
const object = {};
u.freeze(object);
if (typeof process !== 'undefined') {
it('does not freeze in production', () => {
process.env.NODE_ENV = 'production';
const object = {};
u.freeze(object);
expect(Object.isFrozen(object)).to.be.false;
});
expect(Object.isFrozen(object)).to.be.false;
});
}
it('handles null objects', () => {
const object = { foo: null };