码迷,mamicode.com
首页 > Windows程序 > 详细

Sass Loader报错:ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.

时间:2019-12-14 14:05:04      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:res   ISE   解决   ali   pre   The   pack   css   init   

在vue.config.js中引入sass全局配置后报错
vue.config.js代码如下:
module.exports = {
  devServer: {
    port: 3333,
    open: true
  },
  css: {
    loaderOptions: {
      sass: {
        data: `@import "@/assets/scss/_variable.scss";`
      }
    }
  }
}

_variable.scss的代码如下:

$theme-color: #33aef0;

组件中的scss代码如下:

<style lang="scss">
#app {
  color: $theme-color;
  height: 100vh;
}
</style>

页面报错如下:

./src/assets/scss/reset.scss (./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-3-1!./node_modules/postcss-loader/src??ref--8-oneOf-3-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-3-3!./src/assets/scss/reset.scss)
Module build failed (from ./node_modules/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 (E:\element-ui\vue-manage-system\node_modules\schema-utils\dist\validate.js:85:11)
    at Object.loader (E:\element-ui\vue-manage-system\node_modules\sass-loader\dist\index.js:36:28)
解决办法:
将data改成
prependData
// 旧
data: `@import "~@/assets/scss/variables.scss";`
// 新
prependData: `@import "~@/assets/scss/variables.scss";`

Sass Loader报错:ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.

标签:res   ISE   解决   ali   pre   The   pack   css   init   

原文地址:https://www.cnblogs.com/xifeng59/p/12038878.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!