File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import path from "path" ;
22
33import HtmlWebpackPlugin from "html-webpack-plugin" ;
4+ import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer" ;
45import webpack from "webpack" ;
56
67export default async ( env , options ) => {
78 const dev = options . mode === "development" ;
89 const config = {
910 optimization : {
10- minimize : false ,
11+ minimize : ! dev ,
12+ splitChunks : {
13+ chunks : "all" ,
14+ } ,
1115 } ,
1216 devtool : dev ? "source-map" : false ,
1317 entry : "./js/ispy.js" ,
@@ -47,6 +51,14 @@ export default async (env, options) => {
4751 } ) ,
4852 ] ,
4953 } ;
50-
54+ if ( env && env . analyze ) {
55+ config . plugins . push (
56+ new BundleAnalyzerPlugin ( {
57+ analyzerMode : "static" , // generates a file
58+ openAnalyzer : true , // opens the report in browser
59+ reportFilename : path . resolve ( "dist" , "bundle-report.html" ) ,
60+ } ) ,
61+ ) ;
62+ }
5163 return config ;
5264} ;
You can’t perform that action at this time.
0 commit comments