Fork me on GitHub

dva alias

roadhog2.0 去掉了 .roadhogrc,改用 .webpackrc

设置 alias

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
安装 module-resolver
$ npm install --save-dev babel-plugin-module-resolver

.webpackrc 文件中添加 extraBabelPlugins
{
"extraBabelPlugins" : [
["module-resolver", {
"root": ["./"],
"alias": {
"components":"./src/components",
"utils":"./src/utils",
"services":"./src/services",
"models":"./src/models",
"src": "./src"
}
}]
]
}

import helper from 'utils/helper';
-------------感谢您的阅读 有问题请留言(或mailto:frostbelt@sina.cn)-------------