SoFunction
Updated on 2025-04-04

How to add less and sass in vue-cli

The sass and lass configurations have been built-in in vue-cli. If you need it, just download two modules.

npm install node-sass --save-dev
npm install sass-loader --save-dev

If it is a Taobao image, it will be the same as running cnpm directly.

Then add language to the style in the component or view

<style lang="sass" scoped>
  .....
</style>

It should be noted here that scoped allows styles to only work in the current component or view.

If less, two loaders are required

npm install less --save-dev
npm install less-loader --save-dev

The rest are the same.

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.