File tree Expand file tree Collapse file tree 4 files changed +39
-26
lines changed Expand file tree Collapse file tree 4 files changed +39
-26
lines changed Original file line number Diff line number Diff line change @@ -62,18 +62,20 @@ var Config = function () {
62
62
value : function setExports ( files ) {
63
63
var _this = this ;
64
64
65
- [ ] . concat ( files ) . forEach ( function ( file ) {
66
- var entryFile = Array . isArray ( file ) ? file [ file . length - 1 ] : file ;
67
-
68
- var name = entryFile ;
69
- if ( name . indexOf ( './' ) == 0 ) {
70
- name = name . substring ( 2 ) ;
71
- } else if ( name [ 0 ] == '/' ) {
72
- name = name . substring ( 1 ) ;
73
- }
74
- _this . _config . entry [ name ] = Array . isArray ( file ) ? file : [ file ] ;
75
- } ) ;
76
- return this ;
65
+ if ( files && Array . isArray ( files ) ) {
66
+ [ ] . concat ( files ) . forEach ( function ( file ) {
67
+ var entryFile = Array . isArray ( file ) ? file [ file . length - 1 ] : file ;
68
+
69
+ var name = entryFile ;
70
+ if ( name . indexOf ( './' ) == 0 ) {
71
+ name = name . substring ( 2 ) ;
72
+ } else if ( name [ 0 ] == '/' ) {
73
+ name = name . substring ( 1 ) ;
74
+ }
75
+ _this . _config . entry [ name ] = Array . isArray ( file ) ? file : [ file ] ;
76
+ } ) ;
77
+ return this ;
78
+ }
77
79
}
78
80
} , {
79
81
key : 'setGroupExports' ,
Original file line number Diff line number Diff line change @@ -159,7 +159,12 @@ var Project = function () {
159
159
this . config . setExports ( configMethod ) ;
160
160
}
161
161
if ( typeof configMethod . config == 'function' ) {
162
- configMethod . config . call ( userConfig , options , this . cwd ) ;
162
+ var userConfigObj = configMethod . config . call ( userConfig , options , this . cwd ) ;
163
+
164
+ this . config . setExports ( userConfigObj . export ) ;
165
+ this . config . setCompiler ( userConfigObj . modifyWebpackConfig ) ;
166
+ this . config . setSync ( userConfigObj . sync ) ;
167
+ this . setCommands ( userConfigObj . commands ) ;
163
168
} else {
164
169
error ( this . configFile + ' 没有 exports 正确的方法!' ) ;
165
170
return this ;
Original file line number Diff line number Diff line change @@ -56,18 +56,20 @@ class Config {
56
56
} ;
57
57
}
58
58
setExports ( files ) {
59
- [ ] . concat ( files ) . forEach ( ( file ) => {
60
- const entryFile = Array . isArray ( file ) ? file [ file . length - 1 ] : file
59
+ if ( files && Array . isArray ( files ) ) {
60
+ [ ] . concat ( files ) . forEach ( ( file ) => {
61
+ const entryFile = Array . isArray ( file ) ? file [ file . length - 1 ] : file
61
62
62
- var name = entryFile ;
63
- if ( name . indexOf ( './' ) == 0 ) {
64
- name = name . substring ( 2 ) ;
65
- } else if ( name [ 0 ] == '/' ) {
66
- name = name . substring ( 1 ) ;
67
- }
68
- this . _config . entry [ name ] = Array . isArray ( file ) ? file : [ file ] ;
69
- } ) ;
70
- return this ;
63
+ var name = entryFile ;
64
+ if ( name . indexOf ( './' ) == 0 ) {
65
+ name = name . substring ( 2 ) ;
66
+ } else if ( name [ 0 ] == '/' ) {
67
+ name = name . substring ( 1 ) ;
68
+ }
69
+ this . _config . entry [ name ] = Array . isArray ( file ) ? file : [ file ] ;
70
+ } ) ;
71
+ return this ;
72
+ }
71
73
}
72
74
setGroupExports ( group , exportsArr ) {
73
75
let exportGroup = this . _config . entryGroup ;
@@ -114,7 +116,6 @@ class Config {
114
116
} )
115
117
}
116
118
117
-
118
119
// 处理alias
119
120
const context = nextConfig . context || this . _config . context
120
121
const relativeContext = sysPath . relative ( this . _config . cwd , context )
Original file line number Diff line number Diff line change @@ -131,7 +131,12 @@ class Project {
131
131
this . config . setExports ( configMethod ) ;
132
132
}
133
133
if ( typeof configMethod . config == 'function' ) {
134
- configMethod . config . call ( userConfig , options , this . cwd ) ;
134
+ const userConfigObj = configMethod . config . call ( userConfig , options , this . cwd ) ;
135
+
136
+ this . config . setExports ( userConfigObj . export ) ;
137
+ this . config . setCompiler ( userConfigObj . modifyWebpackConfig ) ;
138
+ this . config . setSync ( userConfigObj . sync ) ;
139
+ this . setCommands ( userConfigObj . commands ) ;
135
140
} else {
136
141
error ( this . configFile + ' 没有 exports 正确的方法!' ) ;
137
142
return this ;
You can’t perform that action at this time.
0 commit comments