webpack4 mini-css-extract-plugin with bourbon



我有我的 scss 文件,它导入了一个 scss 文件,该文件进一步导入波旁威士忌和波旁威士忌。我什至在论坛上搜索了各种问题,但没有找到在 scsss 到 css 转换中的问题,情况是包括波旁威士忌。

网络包 4.28.1迷你 css-extract-plugin 0.5.0

我看到以下错误:

Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/sass-loader/lib/loader.js??ref--5-2!src/component/styles/main.scss:enter code here
Entrypoint mini-css-extract-plugin = *
[./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js?!./src/component/styles/main.scss] ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/component/styles/main.scss 373 bytes {mini-css-extract-plugin} [built] [failed] [1 error]
ERROR in ./src/component/styles/main.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/component/styles/main.scss)
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
var path = require('path');
^
      Invalid CSS after "v": expected 1 selector or at-rule, was "var path = require("
      in /Users/../node_modules/bourbon/index.js (line 1, column 1)

我的 webpack.config.js 文件在这里

const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = {
    entry: {
        "app": ['whatwg-fetch',"./src/component/index.ts", "./src/component/styles/main.scss"],
        "app-helper": "./src/component/helpers.ts"
    },
    output: {
        path: path.resolve(__dirname, './src/component/dist'),
        filename: "[name].bundle.js"
    },
    module: {
        rules: [
            {
                test: /.tsx?$/,
                use: 'ts-loader',
                exclude: /node_modules/
            },
            test: /.(sa|sc|c)ss$/,
            use: [
                MiniCssExtractPlugin.loader,
                'css-loader',
                {
                    loader: "sass-loader",// compiles Sass to CSS
                    options: {
                        includePaths: [
                            'node_modules/bourbon/app/assets/stylesheets',
                            'node_modules/bourbon-neat/app/assets/stylesheets'
                        ]
                    }
                }
            ],
        ]
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: './src/component/dist/output-style.css',
        })
    ],
    optimization: {
        minimizer:[
            new UglifyJSPlugin({
                cache: true,
                parallel: true,
                sourceMap: true // set to true if you want JS source maps
            }),
            new OptimizeCSSAssetsPlugin({})
        ]
    }
}

请提供您的宝贵建议。

事实证明,

这是 sass-loader 版本 7.x 的问题。我将 sass-loader 依赖项改回 6.0.7,它开始像魅力一样工作。这是堆栈溢出线程,它帮助

角 2 节点波旁威士忌错误

相关内容

  • 没有找到相关文章