“typeerror:在使用webpack生成时在弱集中使用了无效值”

jpfvwuh4  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(424)

我正在尝试将SCS添加到项目中。我想从scss文件中构建css文件,但由于我添加了minicssextractplugin,所以出现了一个错误,上面写着“typeerror:在弱集中使用的值无效”。这是我的webpack.config.js:

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const config = {
  // TODO: Add common Configuration
  module: {},
};

const js = Object.assign({}, config, {
  name: 'js',
  entry: path.resolve(__dirname, 'index.js'),
  output: {
    path: path.resolve(__dirname, '../some/path/here'),
    filename: 'main.js',
  },
});

const scss = Object.assign({}, config, {
  name: 'scss',
  entry: path.resolve(__dirname, './scss/styles.scss'),
  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name].css',
    }),
  ],
  module: {
    rules: [
      {
        test: /\.(s*)css$/,
        use: [
          MiniCssExtractPlugin.loader,
          'css-loader',
          {
            loader: 'sass-loader',
            options: {
              implementation: require('sass'),
            },
          },
        ],
      },
    ],
  },
  output: {
    path: path.resolve(__dirname, '../some/path/here'),
    filename: 'styles.css',
  },
});

module.exports = [js, scss];

我在谷歌上搜索了很多,但没有找到任何答案。我使用node.jsv8.4.0。
控制台输出(还有更多,但我认为这已经足够):

TypeError: Invalid value used in weak set
    at WeakSet.add (native)
    at MiniCssExtractPlugin.apply (/path/path/path/path/path/path/path/node_modules/mini-css-extract-plugin/dist/index.js:362:18)

ps:我是webpack的新手,所以如果您能帮助我改进此代码,我将非常高兴。其主要思想是保持js编译不变,并添加scss编译。我还想将包含的scss文件编译为单独的文件。
如果你需要更多的信息,我会提供一些,因为idk还有什么有用的。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题