Webpack 2 =意外的角色@

时间:2017-02-24 05:12:48

标签: webpack gulp vuejs2 webpack-2

我尝试使用命令gulp编译我的项目但是我收到了这个错误。

Module parse failed: /node_modules/element-ui/lib/theme-default/index.css Unexpected character '@' (1:0)
message: './~/element-ui/lib/theme-default/index.css\nModule parse failed: /Users/leococo/Site/mtlgigsGood/node_modules/element-ui/lib/theme-default/index.css Unexpected character \'@\' (1:0)\nYou may need an appropriate loader to handle

导致问题的文件以:

开头
@charset "UTF-8";

如果我采用webpack v1语法而不是webpack v2

,这是有效的

WEBPACK v2 gulp.js(不工作)

 Elixir.webpack.mergeConfig({
        resolveLoader: {
            root: path.join(__dirname, 'node_modules'),
        },
        // other options...
        module: {
            // module.rules is the same as module.loaders in 1.x
            rules: [
                {
                    test: /\.css$/,
                    loader: 'style!css'
                },
            ],
        },
    });

WEBPACK v1 gulp.js(工作)

Elixir.webpack.mergeConfig({
        resolveLoader: {
            root: path.join(__dirname, 'node_modules'),
        },
        module: {
            loaders: [
                {
                    test: /\.css$/,
                    loader: 'style!css'
                }]
        },
    });

1 个答案:

答案 0 :(得分:0)

  {
    test: /\.css$/,
    loader: 'style-loader!css-loader'
  },

从那里webpack module parse failed Unexpected character '@'