Open sandercage opened 6 years ago
同求一个实例
是不是要改成 .webpackrc.js
才可以呢, 我也很想知道
确实是要改成 .webpackrc.js
alias 就可以生效了
.webpackrc.js 这个也不行呢?
dva-cli version 0.9.2
dva version 2.1.0
roadhog version 2.2.0
刚试了,直接改为 .webpackrc.js
是不行的,需要修改为path.resolve 才行,应该是路径不对,具体如下:
const path = require('path');
export default {
"alias": {
"components": path.resolve(__dirname, "./src/components"),
"models": path.resolve(__dirname, "./src/models"),
"routes": path.resolve(__dirname, "./src/routes")
}
}
If you run roadhog test
the alias does not work.
Set alias in .babelrc with babel-plugin-module-resolver should be work for roadhog test.
I did that already and specified
{
"plugins": [
["babel-plugin-module-resolver", {
"alias": {
"components": "./src/components",
}
}]
]
}
but it does not work. I also don't see that .babelrc
is anywhere mentioned in the code of roadhog. How does it work?
I work with unmodified @ant-design-pro which contains this bug https://github.com/ant-design/ant-design-pro/issues/1133
Well thats exactly the example I used and it does not work. It could be an issue specifically with antd-pro (which I doubt), but to be honest I could not find any example on github where roadhog test
is used together with an alias.
Haven't tried antd-pro yet. The example here is good.
I just solved my question on that way,thx
alias 字段配置如下:
但是import时无法识别这个路径:import xxx from "routes/xxx.js"