This plugin extract CSS into separate files. It creates a CSS file per JS file which contains CSS. It supports On-Demand-Loading of CSS and SourceMaps.
It builds on top of a new webpack v4 feature (module types) and requires webpack 4 to work.
Compared to the extract-text-webpack-plugin:
- Async loading
- No duplicate compilation (performance)
- Easier to use
- Specific to CSS
TODO:
- HMR support
Install
npm install --save-dev mini-css-extract-plugin
Usage
Configuration
webpack.config.js
const MiniCssExtractPlugin = ;moduleexports = plugins: // Options similar to the same options in webpackOptions.output // both options are optional filename: "[name].css" chunkFilename: "[id].css" module: rules: test: /\.css$/ use: MiniCssExtractPluginloader "css-loader"
Maintainers
Tobias Koppers |