Path aliases for imports in WebStorm

前端 未结 10 1940
日久生厌
日久生厌 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:09

    This is answered in a comment but to save people digging into comments and link only information, here it is:

    As of WS2017.2 this will be done automatically. The information is here.

    According to this, webstorm will automatically resolve aliases that are included within the webpack.config in the root of the project. If you have a custom structure and your webpack.config isn't in the root folder then go to Settings | Languages & Frameworks | JavaScript | Webpack and set the option to the config you require.

    Note: Most setups have a base config which then call a dev or prod version. In order for this to work properly, you need to tell webstorm to use the dev one.

提交回复
热议问题