vue 3.x - 安装scss/sass
1.首先执行以下命令安装 style-resources-loader;
vue add style-resources-loader
2.然后安装scss/sass,node-sass sass-loader sass 属于重要依赖,所以需-D而不是-S;
npm install node-sass sass-loader sass -D
3.根路径下建立文件vue.config.js
const path = require('path'); module.exports = { pluginOptions: { 'style-resources-loader': { preProcessor: 'scss', patterns: [] } } }
4.调用test
<style lang="scss" scoped> $bg: red; .container { background-color: $bg; } </style>