vue cli3使用官方方法配置sass全局變量報錯

更新的scss版本在vue cli3的項目裏面的配置須要修改參數設置,具體在vue.config.js文件css

sass-loader報錯:
Module build failed (from ./node_modules/_sass-loader@8.0.0@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.vue

  • options has an unknown property 'data'. These properties are valid:
  • object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
  • at validate (D:舊項目webDemonode_modules_schema-utils@2.2.0@schema-utilsdistvalidate.js:49:11)
  • at Object.loader (D:舊項目webDemonode_modules_sass-loader@8.0.0@sass-loaderdistindex.js:36:28)

注:(D:舊項目webDemo)是咱們本身的項目存放的路徑node

css: {
    loaderOptions: {
      sass: {
        data: `@import "~@/assets/scss/variables.scss";`, //這兒的鍵名改了
      },
    }
  }
// 舊
data: `@import "~@/assets/scss/variables.scss";`
// 新
prependData: `@import "~@/assets/scss/variables.scss";`
相關文章
相關標籤/搜索