Importing Sass through npm

后端 未结 5 1353
闹比i
闹比i 2020-12-13 17:18

Currently in our Sass files we have something like the following:

@import \"../../node_modules/some-module/sass/app\";

This is bad, because

5条回答
  •  囚心锁ツ
    2020-12-13 18:16

    If you are looking for a handy answer in 2017 and are using Webpack, this was the easiest I found.

    Suppose your module path is like:

    node_modules/some-module/sass/app
    

    Then in your main scss file you can use:

    @import "~some-module/sass/app";
    

    Tilde operator shall resolve any import as a module.

提交回复
热议问题