I get this error when I build webpack:
ERROR in chunk plugin.min [entry] ./plugin.min.css Conflict: Multiple chunks emit assets to the same filename ./plugin.min.css (chunks 0 and 1)
Here is my webpack.config.js file:
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;
};
I am guessing this is because I am using the same extract block filename? I have multiple entry points so not sure if that could cause the error I am seeing. Do I need to add more css file names/mini css extract plugins?
Try this using mini-css-extract-plugin
new MiniCssExtractPlugin({
filename: "[name]/../style.css"
}),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.