vuecli3使用官方方法配置sass全局变量报错 options has an unknown property 'data'. These properties are valid: object

更新的scss版本在vue cli3的项目里面的配置需要修改参数设置,具体在vue.config.js文件

sass-loader报错:
Module build failed (from ./node_modules/[email protected]@sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API
schema.

  • options has an unknown property ‘data’. These properties are valid:
    object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (D:\workspace\vuecli\elemdemo\[email protected]@schema-utils\dist\validate.js:50:11)
    at Object.loader (D:\workspace\vuecli\elemdemo\[email protected]@sass-loader\dist\index.js:36:28)
    解决方案:
    将 data 改成prependData
css: {
      loaderOptions: {
        sass: {
          prependData: `
            @import "@/assets/css/index.scss";
          `
        }
      }
    }

你可能感兴趣的:(vue-cli)