Skip to content

Commit

Permalink
add webpack stats
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtran committed Mar 17, 2020
1 parent 231524c commit 53adce1
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,3 +24,4 @@ yarn-error.log*
coverage
package-lock.json
.vscode/settings.json
statistics.html
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -88,7 +88,8 @@
"sass-loader": "^8.0.2",
"typescript": "^3.7.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.11"
"webpack-cli": "^3.3.11",
"webpack-visualizer-plugin": "^0.1.11"
},
"files": [
"dist"
Expand Down
17 changes: 15 additions & 2 deletions webpack.config.js
@@ -1,8 +1,10 @@
// Webpack configuration
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const isProduction = process.env.NODE_ENV === 'production';
const supportServerSide = !!process.env.SERVER_SIDE;
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const Visualizer = require('webpack-visualizer-plugin');

module.exports = {
mode: isProduction ? 'production' : 'development',
Expand Down Expand Up @@ -50,5 +52,16 @@ module.exports = {
},
],
},
plugins: [new MiniCssExtractPlugin()],
optimization: {
minimizer: [new TerserPlugin()],
},
plugins: [
new MiniCssExtractPlugin(),
new Visualizer({
filename: '../statistics.html'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
})
],
};

0 comments on commit 53adce1

Please sign in to comment.