报错信息:
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
报错写法如下:
{ loader: "sass-loader", options: { data: ` $env: ${process.env.NODE_ENV};
@import "sass/_fn.scss"; @import "sass/_mixins.scss"; @import "sass/_var.scss"; ` } }
报错原因:
新版sass-loader改了options参数名,把data改为了prependData,参考:https://github.com/webpack-contrib/sass-loader#prependdata
正确写法:
{ loader: "sass-loader", options: { prependData: ` $env: ${process.env.NODE_ENV};
@import "sass/_fn.scss"; @import "sass/_mixins.scss"; @import "sass/_var.scss"; ` } }