[Vuejs] node16+,node-sass,sass-loader版本兼容

node16+ 对应的node-sass,sass-loader版本

"sass-loader": "^10.2.0",
"node-sass": "^6.0.1",

 

如果报错:

Syntax Error: ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'prependData'. These properties are valid:
   object { implementation?, sassOptions?, additionalData?, sourceMap?, webpackImporter? }

则检查webpack配置:

module.exports = {
  css: {
    loaderOptions: {
      sass: { // 加载全局scss文件
        additionalData: '@import "@/assets/css/common/common.scss";'
      }
    }
  },  
}

 

由于sass-loader版本不同,loaderOptions中additionalData的键名也不同,

sass-loader v8-, 选项名是 "data"
sass-loader v8,选项名是 "prependData"
sass-loader v10+, 选项名是 "additionalData"

 

posted on 2021-08-23 11:26  晏过留痕  阅读(7057)  评论(2编辑  收藏  举报