Path aliases for imports in WebStorm

前端 未结 10 1907
日久生厌
日久生厌 2020-12-02 05:31

I use webpack path aliases for ES6 module loading.

E.g. If I define an alias for utils instead of something like
import Foo from \".

10条回答
  •  眼角桃花
    2020-12-02 06:19

    You can define custom paths, so WebStorm/PhpStorm can understand your aliases. But make sure, they are identical with your aliases. Create file in your root directory and call it something like this: webStorm.config.js (any js file will be ok). Then configure your paths inside:

    System.config({
      "paths": {
        "components/*": "./src/components/*",
        "core/*": "./src/core/*",
        ...
      }
    });
    

    WebStorm/PhpStorm will recognize System as it's own module and will treat this file as configuration.

提交回复
热议问题