如何在最新的 vue-cli 启动项目中使用 SASS/SCSS? [英] How to use SASS / SCSS with latest vue-cli starter project?

查看:37
本文介绍了如何在最新的 vue-cli 启动项目中使用 SASS/SCSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的项目中使用 SASS 或 SCSS.

I need to use SASS or SCSS in my project.

我使用 vue-cli 制作了一个最新版本的入门项目.

I used the vue-cli to make the latest version of a starter project.

有人在使用 webpack 的最新入门项目中成功地使 sass/scss 工作吗?

Anyone had any success in making sass/scss work in the newest starter project with webpack?

推荐答案

  1. 你安装必要的依赖项

  1. you install the necessary dependencies

npm install -D node-sass sass-loader

对于全局样式,只需将文件导入main.js:

for global styles, simply import the file into main.js:

import './styles/my-styles.scss'

.vue 文件中,将 lang 添加到 <style> 元素.

in .vue files, add the lang to the <style> element.

<style lang="scss">

如果使用 webstorm:

If using webstorm:

<style lang="scss" rel="stylesheet/scss">

这篇关于如何在最新的 vue-cli 启动项目中使用 SASS/SCSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆