Skip to content

Commit c6aead5

Browse files
Update doc (#1826)
Co-authored-by: Liam Ma <[email protected]>
1 parent c321da7 commit c6aead5

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

website/packages/docs/src/pages/css-extraction-webpack.mdx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ module.exports = {
173173
],
174174
},
175175
plugins: [
176+
// Hash your files unless it's explicitly unnecessary in your build system.
177+
// To achieve this, pass the filename option to the MiniCssExtractPlugin,
178+
// including [contenthash] in the name.
176179
+ new MiniCssExtractPlugin({ filename: '[name].[contenthash].css' }),
177180
new CompiledExtractPlugin(),
178181
],
@@ -215,30 +218,14 @@ module.exports = {
215218
],
216219
},
217220
plugins: [
218-
+ new MiniCssExtractPlugin(),
221+
new MiniCssExtractPlugin({ filename: '[name].[contenthash].css' }),
219222
new CompiledExtractPlugin(),
220223
],
221224
};
222225
```
223226

224227
All extracted styles will be placed in a file called `compiled-css.css`.
225228

226-
### Production optimization
227-
228-
#### Filename
229-
230-
Some production environments may require you to include a hash in the filename to allow the stylesheet to be cached correctly.
231-
232-
To do this, pass the `filename` option to the extract plugin, including `[contenthash]` in the name.
233-
234-
```diff
235-
// webpack.config.js
236-
-new MiniCssExtractPlugin()
237-
+new MiniCssExtractPlugin({ filename: '[name].[contenthash].css' })
238-
```
239-
240-
See the [`mini-css-extract-plugin` docs](https://github.com/webpack-contrib/mini-css-extract-plugin/#long-term-caching) for more information on the available options.
241-
242229
### CSS minification
243230

244231
Turn on the [minimizer plugin](https://github.com/webpack-contrib/mini-css-extract-plugin/#minimizing-for-production).

0 commit comments

Comments
 (0)