@@ -43,26 +43,21 @@ module.exports = {
43
43
// These are the "entry points" to our application.
44
44
// This means they will be the "root" imports that are included in JS bundle.
45
45
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
46
- entry : [
47
- // Include an alternative client for WebpackDevServer. A client's job is to
48
- // connect to WebpackDevServer by a socket and get notified about changes.
49
- // When you save a file, the client will either apply hot updates (in case
50
- // of CSS changes), or refresh the page (in case of JS changes). When you
51
- // make a syntax error, this client will display a syntax error overlay.
52
- // Note: instead of the default WebpackDevServer client, we use a custom one
53
- // to bring better experience for Create React App users. You can replace
54
- // the line below with these two lines if you prefer the stock client:
55
- // require.resolve('webpack-dev-server/client') + '?/',
56
- // require.resolve('webpack/hot/dev-server'),
57
- require . resolve ( 'react-dev-utils/webpackHotDevClient' ) ,
58
- // We ship a few polyfills by default:
59
- require . resolve ( './polyfills' ) ,
60
- // Finally, this is your app's code:
61
- paths . appIndexJs
62
- // We include the app code last so that if there is a runtime error during
63
- // initialization, it doesn't blow up the WebpackDevServer client, and
64
- // changing JS code would still trigger a refresh.
65
- ] ,
46
+ // todo comments
47
+ entry : Object . assign ( {
48
+ index : [
49
+ require . resolve ( 'react-dev-utils/webpackHotDevClient' ) ,
50
+ require . resolve ( './polyfills' ) ,
51
+ paths . appIndexJs ,
52
+ ] ,
53
+ polyfills : [ require . resolve ( './polyfills' ) ] ,
54
+ } , Object . keys ( paths . appEntries ) . reduce ( ( entries , chunk ) => {
55
+ entries [ chunk ] = [
56
+ require . resolve ( 'react-dev-utils/webpackHotDevClient' ) ,
57
+ paths . appEntries [ chunk ] ,
58
+ ] ;
59
+ return entries ;
60
+ } , { } ) ) ,
66
61
output : {
67
62
// Next line is not used in dev but WebpackDevServer crashes without it:
68
63
path : paths . appBuild ,
@@ -71,7 +66,7 @@ module.exports = {
71
66
// This does not produce a real file. It's just the virtual path that is
72
67
// served by WebpackDevServer in development. This is the JS bundle
73
68
// containing code from all our entry points, and the Webpack runtime.
74
- filename : 'static/js/bundle .js' ,
69
+ filename : 'static/js/[name] .js' ,
75
70
// This is the URL that app is served from. We use "/" in development.
76
71
publicPath : publicPath
77
72
} ,
@@ -208,6 +203,17 @@ module.exports = {
208
203
new HtmlWebpackPlugin ( {
209
204
inject : true ,
210
205
template : paths . appHtml ,
206
+ chunks : [ 'index' ] ,
207
+ } ) ,
208
+ // todo comment
209
+ ...Object . keys ( paths . appEntries ) . map ( ( chunk ) => {
210
+ return new HtmlWebpackPlugin ( {
211
+ inject : true ,
212
+ template : paths . appHtml ,
213
+ chunks : [ 'polyfills' , chunk ] ,
214
+ chunksSortMode : 'none' , // todo fix
215
+ filename : chunk + '.html' ,
216
+ } ) ;
211
217
} ) ,
212
218
// Makes some environment variables available to the JS code, for example:
213
219
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
0 commit comments