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
Copy file name to clipboardExpand all lines: README.md
+46-39
Original file line number
Diff line number
Diff line change
@@ -155,12 +155,12 @@ module.exports = {
155
155
### `esModule`
156
156
157
157
Type: `Boolean`
158
-
Default: `false`
158
+
Default: `true`
159
159
160
-
By default, `mini-css-extract-plugin` generates JS modules that use the CommonJS modules syntax.
160
+
By default, `mini-css-extract-plugin` generates JS modules that use the ES modules syntax.
161
161
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
162
162
163
-
You can enable a ES module syntax using:
163
+
You can enable a CommonJS syntax using:
164
164
165
165
**webpack.config.js**
166
166
@@ -177,7 +177,7 @@ module.exports = {
177
177
{
178
178
loader:MiniCssExtractPlugin.loader,
179
179
options: {
180
-
esModule:true,
180
+
esModule:false,
181
181
},
182
182
},
183
183
'css-loader',
@@ -297,7 +297,6 @@ module.exports = {
297
297
// you can specify a publicPath here
298
298
// by default it uses publicPath in webpackOptions.output
299
299
publicPath:'../',
300
-
hmr:process.env.NODE_ENV==='development', // webpack 4 only
301
300
},
302
301
},
303
302
'css-loader',
@@ -356,32 +355,37 @@ Here is an example to have both HMR in `development` and your styles extracted i
356
355
357
356
(Loaders options left out for clarity, adapt accordingly to your needs.)
358
357
358
+
You should not use `HotModuleReplacementPlugin` plugin if you are using a `webpack-dev-server`.
359
+
`webpack-dev-server` enables / disables HMR using `hot` option.
// Options similar to the same options in webpackOptions.output
416
-
// both options are optional
417
-
filename:'[name].css',
418
-
chunkFilename:'[id].css',
419
-
}),
420
-
],
430
+
plugins,
421
431
module: {
422
432
rules: [
423
433
{
424
434
test:/\.css$/,
425
435
use: [
426
436
{
427
437
loader:MiniCssExtractPlugin.loader,
428
-
options: {
429
-
// only enable hot in development (webpack 4 only)
430
-
hmr:process.env.NODE_ENV==='development',
431
-
// if hmr does not work, this is a forceful method.
432
-
reloadAll:true,
433
-
},
438
+
options: {},
434
439
},
435
440
'css-loader',
436
441
],
@@ -580,9 +585,11 @@ module.exports = {
580
585
};
581
586
```
582
587
583
-
### Module Filename Option
588
+
### Filename Option as function
584
589
585
-
With the `moduleFilename` option you can use chunk data to customize the filename. This is particularly useful when dealing with multiple entry points and wanting to get more control out of the filename for a given entry point/chunk. In the example below, we'll use `moduleFilename` to output the generated css into a different directory.
590
+
With the `filename` option you can use chunk data to customize the filename.
591
+
This is particularly useful when dealing with multiple entry points and wanting to get more control out of the filename for a given entry point/chunk.
592
+
In the example below, we'll use `filename` to output the generated css into a different directory.
0 commit comments