Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 网页包返回验证错误:CSS加载程序选项无效_Reactjs_Webpack_Webpack Dev Server - Fatal编程技术网

Reactjs 网页包返回验证错误:CSS加载程序选项无效

Reactjs 网页包返回验证错误:CSS加载程序选项无效,reactjs,webpack,webpack-dev-server,Reactjs,Webpack,Webpack Dev Server,我得到一个css加载程序无效选项的错误,我的webpack.conifg.js代码如下: const path = require('path'); const HtmlWebPackPlugin = require("html-webpack-plugin"); const htmlWebpackPlugin = new HtmlWebPackPlugin({ template: "./public/index.html" }); module.exports = { en

我得到一个css加载程序无效选项的错误,我的webpack.conifg.js代码如下:

const path = require('path');
const HtmlWebPackPlugin = require("html-webpack-plugin");

const htmlWebpackPlugin = new HtmlWebPackPlugin({
    template: "./public/index.html"
});

module.exports = {
    entry: "./src/index.js",
    output: {
        path: path.resolve('dist'),
        filename: 'bundled.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader"
                }
            },
            {
                test: /\.css$/,
                use: [
                    {
                        loader: "style-loader"
                    },
                    {
                        loader: "css-loader",
                        options: {
                            modules: true,
                            importLoaders: 1,
                            localIdentName:"[name]_[local]_[hash:base64]",
                            sourceMap: true,
                            minimize: true
                        }
                    }
                ]
            },
            { 
                test: /\.(png|jpg|woff|woff2|eot|ttf|svg)$/,
                loader: 'url-loader?limit=100000' 
            }
        ]
    },
plugins: [htmlWebpackPlugin]
};
我不知道我哪里做错了。请帮我解决这个问题。我正在使用ReactJS4的webpack,webpack版本是4。谢谢

试着评论一下:

// minimize: true

注释掉
minimize
以前是有效的,尽管我开始了一个新项目,新安装了
css-loader
,这次的罪魁祸首是
importLoader:1
。只需删除导入加载程序,它就可以工作了


我正在使用带有React的css模块,并且一切都正常运行。

这就是解决我的问题的方法:

css加载器2.1.1 css加载器3.0.0
这适用于我的VUE Js项目:

浏览到
/build/utils.js
文件,并在
css加载器的对象中对标记错误的选项进行注释。就我而言,我不得不评论:


minimize:process.env.NODE_env==='production',

为什么您同时需要css和样式加载器?您是否尝试删除css加载器并只删除样式一?我得到模块解析失败:删除样式加载器后出现意外字符'@'。这对我也有效。语法上有了变化,我很惊讶在任何地方都没有提到它。
{ loader: 'style-loader'},
{
  loader: 'css-loader',
  options: {
    modules: true,
    localIdentName: '[local]',
    import: true,
    importLoaders: true,
  }
},
{ loader: 'sass-loader'}                
{ loader: 'style-loader'},
{
  loader: 'css-loader',
  options: {
    modules: {
      mode: 'local',
      localIdentName: '[local]',
    },
    import: true,
    importLoaders: true,
  }
},
{ loader: 'sass-loader'}