1.安装依赖
npm install --save-dev node-sass
npm install sass-loader css-loader style-loader --save-dev
如果报错:卸载重新安装,如下命令
node-sass安装失败.pngnpm uninstall node-sass
npm install node-sass@latest
再执行
npm install sass-loader css-loader style-loader --save-dev
2.webpack.config.js中配置
{
test: /\.scss$/,
loaders: ["style", "css", "sass"]
},
3.开始sass之旅
scoped:只有当前组件可用
<style lang="scss" scoped>
</style>
4.sass文件引入
<style lang="scss">
@import './css/main.scss'
</style>
网友评论