[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"
------------------------------------------------------------------
Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------