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 语义-意外字符'@';带网页包_Reactjs_Webpack_Semantic Ui - Fatal编程技术网

Reactjs 语义-意外字符'@';带网页包

Reactjs 语义-意外字符'@';带网页包,reactjs,webpack,semantic-ui,Reactjs,Webpack,Semantic Ui,错误终端 错误控制台 我发现错误在这一行import'semantic ui css/semantic.css'所以我搜索这种错误,我刚刚安装了url加载器,并保留了相同的错误,这是我的网页配置 module: { loaders: [ { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }, { test: /\.jsx$/, loader: 'babe

错误终端

错误控制台

我发现错误在这一行
import'semantic ui css/semantic.css'
所以我搜索这种错误,我刚刚安装了
url加载器
,并保留了相同的错误,这是我的网页配置

module: {
        loaders: [
            { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
            { test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
            {
                test: /\.(png|woff|woff2|eot|ttf|svg)$/,     <--- this delete a lot of errors with semantic, but wont work with "Unexpected character '@'"
                loader: 'url-loader?limit=100000'
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'eslint-loader'
            },
            {
                test: /\.css$/,
                loaders: [
                    'style-loader?sourceMap',
                    'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
                ],
                exclude: /node_modules/
            },
            {
                test: /\.scss$/,
                loaders: [
                    'style-loader',
                    'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
                    'resolve-url-loader',
                    'sass-loader'
                ],
                exclude: /node_modules/
            }
        ]
    }
模块:{
装载机:[
{test:/\.js$/,loader:'babel loader',exclude:/node\u modules/},
{test:/\.jsx$/,loader:'babel loader',exclude:/node\u modules/},
{
测试:/\(png | woff | woff2 | eot | ttf | svg)$/,更改此项:

{ 
  test: /\.css$/, 
  loaders: [ 'style-loader?sourceMap', 'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]' ],
  exclude: /node_modules/ 
},
为此:

{
  test: /\.css$/,
  loaders: [ 'style-loader?sourceMap', 'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]' ]
}
换句话说…删除
排除

另一个选择是不要像上面提到的那样进行更改…并且您可能不想假设所有节点_模块都使用css模块。我认为这种方式更好…因此,请添加一个附加规则:

{
  test: /\.css$/,
  include: path.resolve('node_modules'),
  use: [
    {
      loader: 'style-loader',
      options: {
        sourceMap: true
      }
    }, {
      loader: 'css-loader',
      options: {
        sourceMap: true
      }
    }
  }]
}`
{
  test: /\.css$/,
  loaders: [ 'style-loader?sourceMap', 'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]' ]
}
{
  test: /\.css$/,
  include: path.resolve('node_modules'),
  use: [
    {
      loader: 'style-loader',
      options: {
        sourceMap: true
      }
    }, {
      loader: 'css-loader',
      options: {
        sourceMap: true
      }
    }
  }]
}`