Node-sass does not understand tilde

后端 未结 2 1598
长情又很酷
长情又很酷 2021-02-20 00:55

Exploring the angular-cli for RC1 of Angular2 released recently I faced strange problem: node-sass within sass plugin in the angular-cli d

2条回答
  •  我寻月下人不归
    2021-02-20 01:16

    Tilde path resolving is something that webpack does, node-sass doesn't have such a resolver built in. sass-loader for webpack has this. You can write your own import resolution alternatively.

    Just for completeness here's how you might do it without webpack/sass-loader using a custom importer:

    function importer(url, prev, done) {
      if (url[0] === '~') {
        url = path.resolve('node_modules', url.substr(1));
      }
    
      return { file: url };
    }
    

提交回复
热议问题