Skip to content

Commit

Permalink
chore(package): minify package bundles in production mode only
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Mar 24, 2018
1 parent 7f42310 commit a5bde82
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 45 deletions.
19 changes: 12 additions & 7 deletions app/scripts/modules/amazon/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand All @@ -55,7 +60,7 @@ module.exports = {
{ loader: 'thread-loader', options: { workers: WEBPACK_THREADS } },
{ loader: 'babel-loader' },
{ loader: 'envify-loader' },
{ loader: 'eslint-loader' } ,
{ loader: 'eslint-loader' },
],
exclude: exclusionPattern
},
Expand Down
17 changes: 11 additions & 6 deletions app/scripts/modules/core/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand Down
19 changes: 12 additions & 7 deletions app/scripts/modules/docker/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand All @@ -54,7 +59,7 @@ module.exports = {
{ loader: 'thread-loader', options: { workers: WEBPACK_THREADS } },
{ loader: 'babel-loader' },
{ loader: 'envify-loader' },
{ loader: 'eslint-loader' } ,
{ loader: 'eslint-loader' },
],
exclude: exclusionPattern
},
Expand Down
19 changes: 12 additions & 7 deletions app/scripts/modules/google/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand All @@ -55,7 +60,7 @@ module.exports = {
{ loader: 'thread-loader', options: { workers: WEBPACK_THREADS } },
{ loader: 'babel-loader' },
{ loader: 'envify-loader' },
{ loader: 'eslint-loader' } ,
{ loader: 'eslint-loader' },
],
exclude: exclusionPattern
},
Expand Down
17 changes: 11 additions & 6 deletions app/scripts/modules/kubernetes/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand Down
17 changes: 11 additions & 6 deletions app/scripts/modules/openstack/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand Down
17 changes: 11 additions & 6 deletions app/scripts/modules/titus/webpack.config.js
Expand Up @@ -9,11 +9,15 @@ const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: 'production',
stats: 'errors-only',
watch: process.env.WATCH === 'true',
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
Expand All @@ -26,13 +30,14 @@ module.exports = {
},
devtool: 'source-map',
optimization: {
minimizer: [
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
}),
],
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
Expand Down

0 comments on commit a5bde82

Please sign in to comment.