Skip to content

Commit dfc9e56

Browse files
committed
feat(plugin): allow config build options
1 parent cd089e1 commit dfc9e56

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/models/Project.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ var Project = function () {
104104
value: function setServer(server) {
105105
this.server = server || {};
106106
}
107+
}, {
108+
key: 'setBuild',
109+
value: function setBuild(build) {
110+
this.build = extend(true, this.build, build);
111+
}
107112
}, {
108113
key: 'readConfig',
109114
value: function readConfig() {
@@ -196,6 +201,7 @@ var Project = function () {
196201
handleExportsConfig.bind(_this2)(_module.config, pluginItem.options);
197202
_this2.setCommands(_module.commands || ykitConfigFile.config.command, pluginName); // 后者兼容以前形式
198203
_this2.setHooks(_module.hooks);
204+
_this2.setBuild(_module.build);
199205
}
200206

201207
// 扩展 eslint 配置
@@ -214,6 +220,7 @@ var Project = function () {
214220
this.setHooks(ykitConfigFile.hooks);
215221
this.setProxy(ykitConfigFile.proxy);
216222
this.setServer(ykitConfigFile.server);
223+
this.setBuild(ykitConfigFile.build);
217224
} else {
218225
logError('Local ' + this.configFile + ' config not found.');
219226
logDoc('http://ued.qunar.com/ykit/docs-配置.html');
@@ -436,7 +443,7 @@ var Project = function () {
436443
cc.enqueue({
437444
opt: opt,
438445
cwd: cwd,
439-
buildOpts: _this4.config.build || {},
446+
buildOpts: _this4.build || _this4.config.build || {},
440447
assetName: asset.name
441448
}, function (err, response) {
442449
if (response.error) {

src/models/Project.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class Project {
9898
this.server = server || {};
9999
}
100100

101+
setBuild(build) {
102+
this.build = extend(true, this.build, build);
103+
}
104+
101105
readConfig() {
102106
if(!this.configFile) {
103107
// no local config, i.e., server command)
@@ -190,6 +194,7 @@ class Project {
190194
handleExportsConfig.bind(this)(module.config, pluginItem.options);
191195
this.setCommands(module.commands || ykitConfigFile.config.command, pluginName); // 后者兼容以前形式
192196
this.setHooks(module.hooks);
197+
this.setBuild(module.build);
193198
}
194199

195200
// 扩展 eslint 配置
@@ -208,6 +213,7 @@ class Project {
208213
this.setHooks(ykitConfigFile.hooks);
209214
this.setProxy(ykitConfigFile.proxy);
210215
this.setServer(ykitConfigFile.server);
216+
this.setBuild(ykitConfigFile.build);
211217
} else {
212218
logError('Local ' + this.configFile + ' config not found.');
213219
logDoc('http://ued.qunar.com/ykit/docs-配置.html');
@@ -431,7 +437,7 @@ class Project {
431437
{
432438
opt: opt,
433439
cwd: cwd,
434-
buildOpts: this.config.build || {},
440+
buildOpts: this.build || this.config.build || {},
435441
assetName: asset.name
436442
},
437443
(err, response) => {

0 commit comments

Comments
 (0)