构建Webpack时出现此错误:
chunk plugin.min中发生错误[entry] ./plugin.min.css 冲突:多个块将资产分配到相同的文件名./plugin.min.css(块0和1)
这是我的 webpack.config.js 文件:
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const debug = process.env.NODE_ENV !== 'production';
const webpack = require('webpack');
var extractBlockSCSS = new MiniCssExtractPlugin({
filename: "./plugin.min.css",
})
var plugins = [
extractBlockSCSS
];
var scssConfig = [
{
loader: process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
];
var config = {
context: __dirname,
devtool: debug ? 'inline-sourcemap' : false,
mode: debug ? 'development' : 'production',
entry: {
'plugin.min': './resources/js/entry.js',
'blocks.build': './resources/blocks/blocks.js'
},
output: {
path: __dirname + '/dist/',
filename: '[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader'
}
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: scssConfig
}
]
},
plugins: plugins
};
module.exports = (env, argv) => {
return config;
};
我猜这是因为我使用了相同的提取块文件名?我有多个入口点,因此不确定是否会导致我看到的错误。我需要添加更多的CSS文件名/迷你CSS提取插件吗?
答案 0 :(得分:0)
使用 mini-css-extract-plugin
尝试一下new MiniCssExtractPlugin({
filename: "[name]/../style.css"
}),