You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main thing is you need to cater for the new chunking system of webpack!
142
+
With **webpack.optimize.CommonsChunkPlugin** plugin no longer part of Webpack 4, we need another way to define the code-splitting. Luckily we have `optimization` configs built into webpack now
131
143
132
144
*webpack.config.js:*
133
145
```js
@@ -151,8 +163,38 @@ module.exports = {
151
163
},
152
164
],
153
165
},
166
+
optimization: {
167
+
// FOR PRODUCTION
168
+
minimizer: [
169
+
newUglifyJSPlugin({
170
+
uglifyOptions: {
171
+
output: {
172
+
comments:false,
173
+
ascii_only:true
174
+
},
175
+
compress: {
176
+
comparisons:false
177
+
}
178
+
}
179
+
})
180
+
],
181
+
// END
182
+
// NEEDED BOTH IN PROD AND DEV BUILDS
183
+
runtimeChunk: {
184
+
name:'bootstrap'
185
+
},
186
+
splitChunks: {
187
+
chunks:'initial', // <-- The key to this
188
+
cacheGroups: {
189
+
vendors: {
190
+
test:/[\\/]node_modules[\\/]/,
191
+
name:'vendor'
192
+
}
193
+
}
194
+
}
195
+
},
154
196
plugins: [
155
-
newExtractCssChunks(),
197
+
newExtractCssChunks({hot:true}), //if you want HMR - we try to automatically inject hot reloading but if its not working, add it to the config
156
198
]
157
199
};
158
200
```
@@ -256,7 +298,7 @@ For example, when running the build using some form of npm script:
0 commit comments