File tree Expand file tree Collapse file tree 5 files changed +370
-13
lines changed Expand file tree Collapse file tree 5 files changed +370
-13
lines changed Original file line number Diff line number Diff line change 9
9
# production
10
10
/build
11
11
12
+ # analyzer
13
+ /stats
14
+
12
15
# misc
13
16
.DS_Store
14
17
.env.local
Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html >
3
3
< head >
4
- < title > My React Configuration Setup </ title >
4
+ < title > JavaScript Patterns </ title >
5
5
</ head >
6
6
< body >
7
- < div id ="root "> </ div >
8
- < script src ="./dist/bundle.js "> </ script >
7
+ < div id ="root " />
9
8
</ body >
10
9
</ html >
Original file line number Diff line number Diff line change 9
9
"scripts" : {
10
10
"start" : " webpack-dev-server --mode development" ,
11
11
"format" : " prettier --write \" src/**/*.js\" " ,
12
+ "stats" : " webpack-bundle-analyzer stats/stats.json" ,
12
13
"build" : " webpack --mode production"
13
14
},
14
15
"devDependencies" : {
21
22
"eslint-config-react" : " ^1.1.7" ,
22
23
"eslint-loader" : " ^2.1.1" ,
23
24
"eslint-plugin-react" : " ^7.12.4" ,
25
+ "html-webpack-plugin" : " ^3.2.0" ,
24
26
"prettier" : " 1.16.2" ,
25
27
"webpack" : " ^4.29.0" ,
28
+ "webpack-bundle-analyzer" : " ^3.0.3" ,
26
29
"webpack-cli" : " ^3.2.1" ,
27
30
"webpack-dev-server" : " ^3.1.14"
28
31
}
Original file line number Diff line number Diff line change 1
1
const path = require ( 'path' ) ;
2
+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
3
+ const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin ;
2
4
3
5
module . exports = {
4
6
devtool : 'inline-source-map' ,
5
7
entry : './src/index.js' ,
6
8
output : {
7
- path : path . join ( __dirname , '/dist ' ) ,
9
+ path : path . join ( __dirname , '/build ' ) ,
8
10
publicPath : '/' ,
9
11
filename : 'bundle.js'
10
12
} ,
13
+ optimization : {
14
+ splitChunks : {
15
+ chunks : 'all'
16
+ }
17
+ } ,
11
18
devServer : {
12
- contentBase : './' ,
13
- publicPath : '/dist/'
19
+ contentBase : './build'
14
20
} ,
15
21
module : {
16
22
rules : [
@@ -20,5 +26,17 @@ module.exports = {
20
26
use : [ 'babel-loader' , 'eslint-loader' ]
21
27
}
22
28
]
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 }
24
42
} ;
You can’t perform that action at this time.
0 commit comments