How to use SASS / SCSS with latest vue-cli starter project?

CommonSenseCode picture CommonSenseCode · May 17, 2017 · Viewed 29.7k times · Source

I need to use SASS or SCSS in my project.

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

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

Answer

Linus Borg picture Linus Borg · May 17, 2017
  1. you install the necessary dependencies

    npm install -D node-sass sass-loader

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

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

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

    <style lang="scss">

If using webstorm:

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