File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99# production
1010/build
1111
12+ # analyzer
13+ /stats
14+
1215# misc
1316.DS_Store
1417.env.local
Original file line number Diff line number Diff line change 11<!DOCTYPE html>
22< html >
33 < head >
4- < title > My React Configuration Setup </ title >
4+ < title > JavaScript Patterns </ title >
55 </ head >
66 < body >
7- < div id ="root "> </ div >
8- < script src ="./dist/bundle.js "> </ script >
7+ < div id ="root " />
98 </ body >
109</ html >
Original file line number Diff line number Diff line change 99 "scripts" : {
1010 "start" : " webpack-dev-server --mode development" ,
1111 "format" : " prettier --write \" src/**/*.js\" " ,
12+ "stats" : " webpack-bundle-analyzer stats/stats.json" ,
1213 "build" : " webpack --mode production"
1314 },
1415 "devDependencies" : {
2122 "eslint-config-react" : " ^1.1.7" ,
2223 "eslint-loader" : " ^2.1.1" ,
2324 "eslint-plugin-react" : " ^7.12.4" ,
25+ "html-webpack-plugin" : " ^3.2.0" ,
2426 "prettier" : " 1.16.2" ,
2527 "webpack" : " ^4.29.0" ,
28+ "webpack-bundle-analyzer" : " ^3.0.3" ,
2629 "webpack-cli" : " ^3.2.1" ,
2730 "webpack-dev-server" : " ^3.1.14"
2831 }
Original file line number Diff line number Diff line change 11const path = require ( 'path' ) ;
2+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
3+ const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin ;
24
35module . exports = {
46 devtool : 'inline-source-map' ,
57 entry : './src/index.js' ,
68 output : {
7- path : path . join ( __dirname , '/dist ' ) ,
9+ path : path . join ( __dirname , '/build ' ) ,
810 publicPath : '/' ,
911 filename : 'bundle.js'
1012 } ,
13+ optimization : {
14+ splitChunks : {
15+ chunks : 'all'
16+ }
17+ } ,
1118 devServer : {
12- contentBase : './' ,
13- publicPath : '/dist/'
19+ contentBase : './build'
1420 } ,
1521 module : {
1622 rules : [
@@ -20,5 +26,17 @@ module.exports = {
2026 use : [ 'babel-loader' , 'eslint-loader' ]
2127 }
2228 ]
23- }
29+ } ,
30+ plugins : [
31+ new HtmlWebpackPlugin ( {
32+ template : path . resolve ( './index.html' )
33+ } ) ,
34+ new BundleAnalyzerPlugin ( {
35+ analyzerMode : 'disabled' ,
36+ generateStatsFile : true ,
37+ statsOptions : { source : false } ,
38+ statsFilename : path . join ( __dirname , 'stats/stats.json' )
39+ } )
40+ ] ,
41+ performance : { hints : false }
2442} ;
You can’t perform that action at this time.
0 commit comments