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
Vue.js 当我将网页3更新为4时收到CssSyntaxError_Vue.js_Webpack_Css Loader_Vue Loader - Fatal编程技术网

Vue.js 当我将网页3更新为4时收到CssSyntaxError

Vue.js 当我将网页3更新为4时收到CssSyntaxError,vue.js,webpack,css-loader,vue-loader,Vue.js,Webpack,Css Loader,Vue Loader,当我将webpack 3更新为4时,我得到了CssSyntaxError。我在前端使用vue和webpack。错误如下 [./node_modules/css-loader/dist/runtime/api.js] 2.35 KiB {mini-css-extract-plugin} [built] ERROR in ./app/javascript/hoge.scss (./node_modules/css-loader/dist/cjs.js??ref--3-2!./app

当我将webpack 3更新为4时,我得到了CssSyntaxError。我在前端使用vue和webpack。错误如下

    [./node_modules/css-loader/dist/runtime/api.js] 2.35 KiB {mini-css-extract-plugin} [built]

    ERROR in ./app/javascript/hoge.scss (./node_modules/css-loader/dist/cjs.js??ref--3-2!./app/javascript/hoge.scss)
    Module build failed (from ./node_modules/css-loader/dist/cjs.js):
    CssSyntaxError

    (891:6) Unknown word

      889 |   background-color: #eeeeee;
      890 |   box-shadow: 0px 0px 5px #000;
    > 891 |   // line-height: 0;
          |      ^
      892 | }
为了更新网页包,我尝试使用MiniCssExtractPlugin。 更新后的npm版本如下所示

webpack                   latest  3.12.0  ❯  4.30.0
webpack-dev-server        latest  2.11.1  ❯  3.3.1 
vue                       latest  2.5.21  ❯  2.6.10
vue-loader                latest  14.2.3  ❯  15.7.0  
css-loader                latest  1.0.1   ❯  2.1.1 
sass-loader@7.1.0
我的webpack.config.js如下所示

const MiniCssExtractPlugin = require('mini-css-extract-plugin')





  plugins: [
    new MiniCssExtractPlugin({
      filename: '[name]-[hash].css'
    }),
    new VueLoaderPlugin()
  ],
  module: {
    rules: [
      {
        test: /\.(scss|sass)$/,
        use: [
          'vue-style-loader',
          {
            loader: MiniCssExtractPlugin.loader
          },
          {
            loader: 'css-loader',
            options: { modules: true }
          },
          {
            loader: 'sass-loader'
          }
        ]
      },
      {
        test: /\.(css)$/,
        use: [
          'vue-style-loader',
          {
            loader: MiniCssExtractPlugin.loader
          },
          {
            loader: 'css-loader',
            options: { modules: true }
          }
        ]
      }
    ]
  }


webpack.config.js中是否存在任何错误设置?

这是我的解决方案-只需在顶部添加“vue样式加载器”:

模块:{
规则:[
{
测试:/\(sa|sc|c)ss$/,
使用:[
“vue样式加载程序”,
{
加载器:MiniCssExtractPlugin.loader,
选项:{
hmr:process.env.NODE_env==='development',
对,,
sourceMap:true
},
},
“css加载程序”,
“sass loader”,
//'邮政编码加载器',
],
},