vue全局配置scss

在 vue.config.js 中配置:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  css: {
    loaderOptions: {
      sass: {
            //单个scss
        additionalData: `@import "@/mixins/mixins.scss";`
           //多个scss
        additionalData: `@import "@/mixins/mixins.scss";
                         @import "@/mixins1/mixins1.scss";`
      },
    }
  }
})

注意

配置文件additionalData: `@import "@/mixins/mixins.scss";`,分号不要忘记;

additionalData 关键字限于 sass-loader V10+版本以上,否则会报错

你可能感兴趣的:(scss,前端,css)