@@ -105,51 +105,36 @@ var Config = function () {
105
105
} , {
106
106
key : 'setCompiler' ,
107
107
value : function setCompiler ( compileConfig ) {
108
- var _this2 = this ;
109
-
110
108
if ( compileConfig ) {
111
- ( function ( ) {
112
- var nextConfig = { } ;
113
-
114
- // 获取用户定义的compile配置
115
- if ( ( typeof compileConfig === 'undefined' ? 'undefined' : _typeof ( compileConfig ) ) === 'object' ) {
116
- nextConfig = compileConfig ;
117
- } else if ( typeof compileConfig === 'function' ) {
118
- nextConfig = compileConfig ( extend ( { } , _this2 . _config ) ) || { } ;
119
- }
109
+ var nextConfig = { } ;
120
110
121
- // 处理context
122
- if ( nextConfig . context && ! sysPath . isAbsolute ( nextConfig . context ) ) {
123
- nextConfig . context = sysPath . resolve ( _this2 . _config . cwd , nextConfig . context ) ;
124
- }
111
+ // 获取用户定义的compile配置
112
+ if ( ( typeof compileConfig === 'undefined' ? 'undefined' : _typeof ( compileConfig ) ) === 'object' ) {
113
+ nextConfig = compileConfig ;
114
+ } else if ( typeof compileConfig === 'function' ) {
115
+ nextConfig = compileConfig ( extend ( { } , this . _config ) ) || { } ;
116
+ }
125
117
126
- // 处理loaders => loader
127
- if ( nextConfig . module && nextConfig . module . loaders ) {
128
- nextConfig . module . loaders . map ( function ( loader , i ) {
129
- if ( loader . loaders && ! loader . loader ) {
130
- loader . loader = loader . loaders . join ( "!" ) ;
131
- }
132
- return loader ;
133
- } ) ;
134
- }
118
+ // 处理 context
119
+ if ( nextConfig . context && ! sysPath . isAbsolute ( nextConfig . context ) ) {
120
+ nextConfig . context = sysPath . resolve ( this . _config . cwd , nextConfig . context ) ;
121
+ }
135
122
136
- // 处理alias
137
- var context = nextConfig . context || _this2 . _config . context ;
138
- var relativeContext = sysPath . relative ( _this2 . _config . cwd , context ) ;
139
- if ( nextConfig . resolve && nextConfig . resolve . alias ) {
140
- ( function ( ) {
141
- var alias = nextConfig . resolve . alias ;
142
- Object . keys ( alias ) . map ( function ( key , i ) {
143
- alias [ key ] = sysPath . relative ( relativeContext , alias [ key ] ) ;
144
- } ) ;
145
- extend ( true , _this2 . _config . resolve . alias , alias ) ;
146
- } ) ( ) ;
147
- }
123
+ // 处理 loaders => loader
124
+ if ( nextConfig . module && nextConfig . module . loaders ) {
125
+ nextConfig . module . loaders . map ( function ( loader , i ) {
126
+ if ( loader . loaders && ! loader . loader ) {
127
+ loader . loader = loader . loaders . join ( "!" ) ;
128
+ }
129
+ return loader ;
130
+ } ) ;
131
+ }
148
132
149
- _this2 . _config . resolve . root . push ( context ) ;
133
+ // 处理 resolve.root
134
+ var context = nextConfig . context || this . _config . context ;
135
+ this . _config . resolve . root . push ( context ) ;
150
136
151
- extend ( true , _this2 . _config , nextConfig ) ;
152
- } ) ( ) ;
137
+ extend ( true , this . _config , nextConfig ) ;
153
138
}
154
139
}
155
140
} , {
0 commit comments