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
132
143
133
144
*webpack.config.js:*
134
145
```js
@@ -152,8 +163,38 @@ module.exports = {
152
163
},
153
164
],
154
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
+
},
155
196
plugins: [
156
-
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
157
198
]
158
199
};
159
200
```
@@ -257,7 +298,7 @@ For example, when running the build using some form of npm script:
0 commit comments