Skip to content

Commit b9c3eb8

Browse files
committed
fix(server): 修复编译config返回undefined时报错
1 parent 656c74e commit b9c3eb8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/models/Project.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ var Project = function () {
164164
if (typeof configMethod.config == 'function') {
165165
var userConfigObj = configMethod.config.call(userConfig, options, this.cwd);
166166

167-
this.config.setExports(userConfigObj.export);
168-
this.config.setCompiler(userConfigObj.modifyWebpackConfig);
169-
this.config.setSync(userConfigObj.sync);
170-
this.setCommands(userConfigObj.commands);
167+
if (userConfigObj) {
168+
this.config.setExports(userConfigObj.export);
169+
this.config.setCompiler(userConfigObj.modifyWebpackConfig);
170+
this.config.setSync(userConfigObj.sync);
171+
this.setCommands(userConfigObj.commands);
172+
}
171173
} else {
172174
error(this.configFile + ' 没有 exports 正确的方法!');
173175
return this;

src/models/Project.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ class Project {
136136
if (typeof configMethod.config == 'function') {
137137
const userConfigObj = configMethod.config.call(userConfig, options, this.cwd);
138138

139-
this.config.setExports(userConfigObj.export);
140-
this.config.setCompiler(userConfigObj.modifyWebpackConfig);
141-
this.config.setSync(userConfigObj.sync);
142-
this.setCommands(userConfigObj.commands);
139+
if(userConfigObj) {
140+
this.config.setExports(userConfigObj.export);
141+
this.config.setCompiler(userConfigObj.modifyWebpackConfig);
142+
this.config.setSync(userConfigObj.sync);
143+
this.setCommands(userConfigObj.commands);
144+
}
143145
} else {
144146
error(this.configFile + ' 没有 exports 正确的方法!');
145147
return this;

0 commit comments

Comments
 (0)