1- const BundleAnalyzerPlugin = require ( "webpack-bundle-analyzer" ) . BundleAnalyzerPlugin
1+ const path = require ( 'path' )
2+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
3+ const BundleAnalyzerPlugin = require ( 'webpack-bundle-analyzer' ) . BundleAnalyzerPlugin
24
35module . exports = function override ( config , env ) {
6+ // compile sass
7+ // https://github.com/facebookincubator/create-react-app/issues/2498
48 config . module . rules [ 1 ] . oneOf . splice ( config . module . rules [ 1 ] . oneOf . length - 1 , 0 ,
59 {
610 test : / \. s c s s $ / ,
@@ -17,8 +21,11 @@ module.exports = function override (config, env) {
1721 } ,
1822 )
1923 if ( env === 'production' ) {
24+ // set the output filename to just socket.js
2025 config . output . filename = 'static/socket.js'
2126 config . output . chunkFilename = 'static/socket.[chunkhash:8].chunk.js'
27+
28+ // if run with `ANALYSE=1 yarn build` create report.js size report
2229 if ( process . env . ANALYSE ) {
2330 config . plugins . push (
2431 new BundleAnalyzerPlugin ( {
@@ -27,6 +34,15 @@ module.exports = function override (config, env) {
2734 } )
2835 )
2936 }
37+ } else {
38+ // add another output file at localhost:3000/foobar/
39+ config . plugins . splice ( 2 , 0 ,
40+ new HtmlWebpackPlugin ( {
41+ inject : true ,
42+ template : path . resolve ( __dirname , 'public' , 'index.html' ) ,
43+ filename : 'foobar/index.html'
44+ } )
45+ )
3046 }
3147 // console.dir(config, { depth: 10, colors: true })
3248 return config
0 commit comments