File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -109,10 +109,12 @@ var Config = function () {
109
109
} , {
110
110
key : 'setCompiler' ,
111
111
value : function setCompiler ( compileConfig ) {
112
+ var _this2 = this ;
113
+
112
114
if ( compileConfig ) {
113
115
var nextConfig = { } ;
114
116
115
- // 获取用户定义的compile配置
117
+ // 获取用户定义的 compile 配置
116
118
if ( ( typeof compileConfig === 'undefined' ? 'undefined' : _typeof ( compileConfig ) ) === 'object' ) {
117
119
nextConfig = compileConfig ;
118
120
} else if ( typeof compileConfig === 'function' ) {
@@ -134,7 +136,19 @@ var Config = function () {
134
136
} ) ;
135
137
}
136
138
137
- // 处理 resolve.root
139
+ // 处理 alias 中 { xyz: "/some/dir" } 的情况
140
+ if ( nextConfig . resolve && nextConfig . resolve . alias ) {
141
+ ( function ( ) {
142
+ var alias = nextConfig . resolve . alias ;
143
+ Object . keys ( alias ) . map ( function ( key , i ) {
144
+ if ( key . indexOf ( '$' ) === - 1 && / ^ \/ .+ / . test ( alias [ key ] ) ) {
145
+ alias [ key ] = sysPath . join ( _this2 . _config . cwd , alias [ key ] ) ;
146
+ }
147
+ } ) ;
148
+ extend ( true , _this2 . _config . resolve . alias , alias ) ;
149
+ } ) ( ) ;
150
+ }
151
+
138
152
var context = nextConfig . context || this . _config . context ;
139
153
this . _config . resolve . root . push ( context ) ;
140
154
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class Config {
97
97
if ( compileConfig ) {
98
98
let nextConfig = { }
99
99
100
- // 获取用户定义的compile配置
100
+ // 获取用户定义的 compile 配置
101
101
if ( typeof compileConfig === 'object' ) {
102
102
nextConfig = compileConfig
103
103
} else if ( typeof compileConfig === 'function' ) {
@@ -119,7 +119,17 @@ class Config {
119
119
} )
120
120
}
121
121
122
- // 处理 resolve.root
122
+ // 处理 alias 中 { xyz: "/some/dir" } 的情况
123
+ if ( nextConfig . resolve && nextConfig . resolve . alias ) {
124
+ let alias = nextConfig . resolve . alias
125
+ Object . keys ( alias ) . map ( ( key , i ) => {
126
+ if ( key . indexOf ( '$' ) === - 1 && / ^ \/ .+ / . test ( alias [ key ] ) ) {
127
+ alias [ key ] = sysPath . join ( this . _config . cwd , alias [ key ] )
128
+ }
129
+ } )
130
+ extend ( true , this . _config . resolve . alias , alias ) ;
131
+ }
132
+
123
133
const context = nextConfig . context || this . _config . context
124
134
this . _config . resolve . root . push ( context )
125
135
You can’t perform that action at this time.
0 commit comments