Sass Loader Error: Invalid options object that does not match the API schema

后端 未结 7 552
别跟我提以往
别跟我提以往 2020-12-16 09:40

I\'m using VueJS with the framework VuetifyJS (v2.0.19). I\'m getting this error after running npm run serve:

Sass Loader has been initialise

7条回答
  •  佛祖请我去吃肉
    2020-12-16 10:24

    If you are using vue-cli 4 and in order to avoid this error you need to change the config of sass-loader in vue.config.js like the example below, after that the error will be fixed.

    const path = require('path');
    
    module.exports = {
      chainWebpack(config) {
        config
          .entry('app')
          .clear()
          .add('./src/core/main.js')
          .end();
        config.resolve.alias
          .set('~', path.join(__dirname, './src'))
          .set('@', path.join(__dirname, './src/core'))
          .set('#', path.join(__dirname, './src/modules'))
      },
      css: {
        loaderOptions: {
          sass: {
            sassOptions: {
              includePaths: [
                path.resolve(__dirname, 'src/core/')
              ],
              indentedSyntax: true,
            },
            prependData: '@import "~@/assets/sass/main.scss"',
          },
        },
      },
      assetsDir: '@/assets/',
    }
    

    Don't forget to specify your own configuration. Please checkout the configuration on the sass-loader repo.

    If you use vue cli 3, it works with sass-loader v7 not with v8 if you use vue cli 3 and sass-loader v7 the previous configuration still works.

    Good luck and regards.

提交回复
热议问题