更新的scss版本在vue cli3的项目里面的配置需要修改参数设置,具体在vue.config.js文件

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.

  • options has an unknown property ‘data’. These properties are valid:
    object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (D:\workspace\vuecli\elemdemo\node_modules_schema-utils@2.5.0@schema-utils\dist\validate.js:50:11)
    at Object.loader (D:\workspace\vuecli\elemdemo\node_modules_sass-loader@8.0.0@sass-loader\dist\index.js:36:28)
    解决方案:
    将 data 改成prependData
css: {
      loaderOptions: {
        sass: {
          prependData: `
            @import "@/assets/css/index.scss";
          `
        }
      }
    }
Logo

前往低代码交流专区

更多推荐