Path aliases for imports in WebStorm

前端 未结 10 1915
日久生厌
日久生厌 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条回答
  •  Happy的楠姐
    2020-12-02 06:10

    Not right now, We were also using path aliases for the files in our react project. The import names were shorter but we lost a lot on static checking of webstorm as well as completion features.

    We later came up with a decision to reduce the code to only 3 levels of depth, as well a single level for the common parts. The path completion feature of webstom (ctrl + space) even helps reduce the typing overhead. The production build does not use longer names, so hardly makes any difference in final code.

    I will suggest please reconsider your decision about aliases. You loose semantic meaning of modules coming from node_modules and your own code, as well as referencing the alias files again and again to make sense of your code, is a much bigger overhead.

提交回复
热议问题