Skip to content

Commit

Permalink
build: Minify only for production
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzahamidi committed Nov 16, 2020
1 parent 5353aec commit c742469
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"mini-css-extract-plugin": "^1.2.1",
"node-sass": "^4.14.1",
"sass-loader": "^10.0.4",
"terser-webpack-plugin": "^5.0.3",
"ts-jest": "^26.4.3",
"ts-loader": "^8.0.7",
"typescript": "^4.0.5",
Expand Down
19 changes: 0 additions & 19 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { merge } = require('webpack-merge');
Expand Down Expand Up @@ -104,24 +103,6 @@ module.exports = function () {
resolve: {
extensions: ['.tsx', '.ts', '.js']
},

optimization: {
minimizer: [new TerserPlugin()],

splitChunks: {
cacheGroups: {
vendors: {
priority: -10,
test: /[\\/]node_modules[\\/]/
}
},

chunks: 'async',
minChunks: 1,
minSize: 30000,
name: false
}
}
}

if (isEnvProduction) return merge(commonConfig, prodConfig);
Expand Down
3 changes: 3 additions & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ module.exports = {
port: 4200,
open: true
},
optimization: {
minimize: false
}
};
21 changes: 20 additions & 1 deletion webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
mode: 'production'
mode: 'production',
optimization: {
minimizer: [new TerserPlugin()],

splitChunks: {
cacheGroups: {
vendors: {
priority: -10,
test: /[\\/]node_modules[\\/]/
}
},

chunks: 'async',
minChunks: 1,
minSize: 30000,
name: false
}
}
};

0 comments on commit c742469

Please sign in to comment.