Skip to content

Commit e2b41ce

Browse files
committed
feat(setConfig): 添加对alias处理
1 parent 8c6302c commit e2b41ce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/models/Config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,19 @@ class Config {
9797
} else if (typeof compileConfig === 'function') {
9898
nextConfig = compileConfig(Object.assign({}, this._config)) || {};
9999
}
100+
100101
if(nextConfig.context && !sysPath.isAbsolute(nextConfig.context)){
101102
nextConfig.context = sysPath.resolve(this._config.cwd, nextConfig.context)
102103
}
103104

105+
if(nextConfig.resolve.alias) {
106+
let alias = nextConfig.resolve.alias
107+
Object.keys(alias).map(function(key, i){
108+
alias[key] = sysPath.relative(nextConfig.context, alias[key])
109+
})
110+
extend(true, this._config.resolve.alias, alias);
111+
}
112+
104113
this._config.resolve.root.push(nextConfig.context)
105114

106115
extend(true, this._config, nextConfig);

0 commit comments

Comments
 (0)