# CSS Extraction
TIP
Only apply CSS extraction for production so that you get CSS hot reload during development.
# webpack 4
npm install -D mini-css-extract-plugin
// webpack.config.js
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
// other options...
module: {
rules: [
// ... other rules omitted
{
test: /\.css$/,
use: [
process.env.NODE_ENV !== 'production'
? 'kdu-style-loader'
: MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
plugins: [
// ... Kdu Loader plugin omitted
new MiniCssExtractPlugin({
filename: 'style.css'
})
]
}
Also see mini-css-extract-plugin docs (opens new window).
# webpack 3
npm install -D extract-text-webpack-plugin
// webpack.config.js
var ExtractTextPlugin = require("extract-text-webpack-plugin")
module.exports = {
// other options...
module: {
rules: [
// ... other rules omitted
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'kdu-style-loader'
})
}
]
},
plugins: [
// ... Kdu Loader plugin omitted
new ExtractTextPlugin("style.css")
]
}
Also see extract-text-webpack-plugin docs (opens new window).
← Custom Blocks Linting →