我是webpack的新手。 我想基于条目文件名创建输出CSS文件。 但是webpack不会在dist(输出路径)中创建css文件。
在webpack -d之后没有错误
项目结构 webpack project structure
我将此cfg用于Webpack。
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: {
index : './src/index.js',
contact: './src/contact.js'
},
output: {
chunkFilename: "[id].js",
path: path.resolve(__dirname,'dist')
},
plugins: [
new HtmlWebpackPlugin({
template: "./src/index.html",
chunks: ['home'],
filename: 'index.html'
}),
new HtmlWebpackPlugin({
template: "./src/contact.html",
chunks: ['contact'],
filename: 'contact.html'
}),
new MiniCssExtractPlugin(
{
filename: '[name].css',
}
)
],
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
],
},
};