webpack将css打包成单个css文件
作者:互联网
- 安装 mini-css-extrack-plugin
yarn add mini-css-extrack-plugin -D
- webpack.config.js 配置
- plugin 配置
const MiniCssExtrackPlugin = require('mini-css-extrack-plugin');
{
plugins: [
new MiniCssExtractPlugin({
filename: 'css/index.css' // 打包后css文件名
})
]
}
- loader 配置
{
module: {
rules: {
test: /\.css$/,
use: ['style-loader', MiniCssExtrackPlugin.loader, 'css-loader']
}
}
}
标签:mini,extrack,plugin,loader,webpack,css,打包 来源: https://www.cnblogs.com/wuchi1111/p/16365917.html