Umi: WEBStorm IDEA Cannot support alias

Created on 20 Sep 2018  ·  17Comments  ·  Source: umijs/umi

WEBStorm IDEA Cannot support alias .
for example :
import PageHeader from '@/components/PageHeader';

默认别名@是src 目录,但是在webstorm 里面,我其实想用鼠标左键进入这个JS。但是进不去。。而且也没有自动路径提示。

FAQ

Most helpful comment

需要配置webstorm下的preference -> language & frameworks -> javascript -> webpack 路径到更目录下的webpack.config.js

All 17 comments

这个肯定点不进去啊

新建 webpack.config.js,内容如下:

module.exports = {
  resolve: {
    alias: {
      '@': require('path').resolve(__dirname, 'src'),
    },
  },
};

@sorrycc 3Q

@sorrycc @xgj1988 为什么我还是不行

@smithyj 我现在也不行了,。

@xgj1988 ts 的话得配置下 paths

@smithyj 你的可以了吗??你说的ts 是typescript 吗?

可以 但是 css 与 img 引入还是存在问题

@smithyj 你是怎么做的呢?

需要配置webstorm下的preference -> language & frameworks -> javascript -> webpack 路径到更目录下的webpack.config.js

可以使用vue里的配置文件。路径如下:

项目路径\node_modules\@vue\cli-service\webpack.config.js

更新到新版本就可以了。。

@shx996 vscode自动加载插件 不需要

@miaozilong 我是说@路径都不能识别。自动加载插件是什么意思?书写的时候提示插件并且自动引入?这个功能webstorm也有,而且主动引入的路径是替换之后的@,反而vscode只能用相对路径来引入。不知道我是否理解你的意思?

@shx996 老哥你解决了吗?我也是用的Path Intellisense 插件只能提示路径,但是VS Code识别不了,无法跳转

@shx996 我的可以用了,需要在package.json同级文件夹新建jsconfig.json文件配置一下,然后重启vs code,链接

可以使用vue里的配置文件。路径如下:

项目路径\node_modules\@vue\cli-service\webpack.config.js

这是正解

Was this page helpful?
0 / 5 - 0 ratings

Related issues

afc163 picture afc163  ·  3Comments

haiing picture haiing  ·  3Comments

zhanchengkun picture zhanchengkun  ·  3Comments

nguyenhuutinh picture nguyenhuutinh  ·  3Comments

ironyfive picture ironyfive  ·  3Comments