|
1 | 1 | import appRootDir from 'app-root-dir'; |
2 | 2 | import AssetsPlugin from 'assets-webpack-plugin'; |
3 | | -import ExtractTextPlugin from 'extract-text-webpack-plugin'; |
| 3 | +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; |
4 | 4 | import UglifyJsPlugin from 'uglifyjs-webpack-plugin'; |
5 | 5 | import nodeExternals from 'webpack-node-externals'; |
6 | 6 | import path from 'path'; |
@@ -66,6 +66,9 @@ export default function webpackConfigFactory(buildOptions) { |
66 | 66 | let webpackConfig = { |
67 | 67 | // Webpack Mode |
68 | 68 | mode: ifDev('development', 'production'), |
| 69 | + // Add context for resolving entry points and loaders from configuration |
| 70 | + // it is recommended to define the context |
| 71 | + context: appRootDir.get(), |
69 | 72 | // Define our entry chunks for our bundle. |
70 | 73 | entry: { |
71 | 74 | // We name our entry files "index" as it makes it easier for us to |
@@ -331,9 +334,9 @@ export default function webpackConfigFactory(buildOptions) { |
331 | 334 | // CSS files. |
332 | 335 | ifProdClient( |
333 | 336 | () => |
334 | | - new ExtractTextPlugin({ |
335 | | - filename: '[name]-[contenthash].css', |
336 | | - allChunks: true, |
| 337 | + new MiniCssExtractPlugin({ |
| 338 | + filename: '[name]-[chunkhash].css', |
| 339 | + chunkFilename: '[name]-[chunkhash].css', |
337 | 340 | }), |
338 | 341 | ), |
339 | 342 |
|
@@ -484,16 +487,13 @@ export default function webpackConfigFactory(buildOptions) { |
484 | 487 | // an ExtractTextPlugin instance. |
485 | 488 | // Note: The ExtractTextPlugin needs to be registered within the |
486 | 489 | // plugins section too. |
487 | | - ifProdClient(() => ({ |
488 | | - loader: ExtractTextPlugin.extract({ |
489 | | - fallback: 'style-loader', |
490 | | - use: ['css-loader'], |
491 | | - }), |
492 | | - })), |
| 490 | + ifProdClient({ |
| 491 | + use: [MiniCssExtractPlugin.loader, 'css-loader'], |
| 492 | + }), |
493 | 493 | // When targetting the server we use the "/locals" version of the |
494 | 494 | // css loader, as we don't need any css files for the server. |
495 | 495 | ifNode({ |
496 | | - loaders: ['css-loader/locals'], |
| 496 | + use: ['css-loader/locals'], |
497 | 497 | }), |
498 | 498 | ), |
499 | 499 | ), |
|
0 commit comments