Sass文件编译两次

时间:2018-06-04 10:49:12

标签: webpack sass-loader mini-css-extract-plugin

我有以下webpack配置:

规则:

{
    test: /\.scss$/,
    use: [
        MiniCssExtractPlugin.loader,
        {
            loader: 'css-loader',
            options: {
                sourceMap: false
            }
        }, {
            loader: 'sass-loader',
            options: {
                sourceMap: false,
                processCssUrls: false
            }
        }
    ]
}

插件:

new MiniCssExtractPlugin({
    filename: '[name].css',
    chunkFilename: '[id].css'
})

使用SpeedMeasurePlugin构建和观看输出时,我得到了这样的输出:

mini-css-extract-plugin, and 
css-loader, and 
sass-loader took 12.73 secs
  module count = 1
css-loader, and 
sass-loader took 12.66 secs
  module count = 1

为什么sass编译两次?

2 个答案:

答案 0 :(得分:0)

它是MiniCssExtractPlugin两次运行sass-loader。不知道为什么。

答案 1 :(得分:0)

这不是 MiniCSSExtractPlugin 的问题。它来自速度测量插件。

参考:https://github.com/webpack-contrib/mini-css-extract-plugin/issues/439