繁体   English   中英

冲突:多个块将资产发送到相同的文件名 ./plugin.min.css

[英]Conflict: Multiple chunks emit assets to the same filename ./plugin.min.css

我在构建 webpack 时收到此错误:

块 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 提取插件吗?

使用mini-css-extract-plugin试试这个

new MiniCssExtractPlugin({
    filename: "[name]/../style.css"
}),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM