Skip to content

Commit cd089e1

Browse files
committed
feat(server): add overlay option
1 parent 18d4d7b commit cd089e1

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

lib/commands/server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,12 @@ exports.run = function (options) {
307307
nextConfig = extend({}, config);
308308

309309
// 注入 sockitIO
310-
nextConfig.module.postLoaders.push({
311-
test: /\.(js)$/,
312-
loader: sysPath.join(__dirname, '../modules/SocketClientLoader.js?cacheId=' + cacheId)
313-
});
310+
if (project.server && project.server.overlay) {
311+
nextConfig.module.postLoaders.push({
312+
test: /\.(js)$/,
313+
loader: sysPath.join(__dirname, '../modules/SocketClientLoader.js?cacheId=' + cacheId)
314+
});
315+
}
314316

315317
if (shouldCompileAllEntries) {
316318
return nextConfig;

lib/models/Project.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ var Project = function () {
9999
value: function setProxy(proxy) {
100100
this.proxy = proxy || [];
101101
}
102+
}, {
103+
key: 'setServer',
104+
value: function setServer(server) {
105+
this.server = server || {};
106+
}
102107
}, {
103108
key: 'readConfig',
104109
value: function readConfig() {
@@ -208,6 +213,7 @@ var Project = function () {
208213
this.setCommands(ykitConfigFile.commands || ykitConfigFile.config.command); // 后者兼容以前形式
209214
this.setHooks(ykitConfigFile.hooks);
210215
this.setProxy(ykitConfigFile.proxy);
216+
this.setServer(ykitConfigFile.server);
211217
} else {
212218
logError('Local ' + this.configFile + ' config not found.');
213219
logDoc('http://ued.qunar.com/ykit/docs-配置.html');

src/commands/server.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,12 @@ exports.run = (options) => {
303303
nextConfig = extend({}, config);
304304

305305
// 注入 sockitIO
306-
nextConfig.module.postLoaders.push({
307-
test: /\.(js)$/,
308-
loader: sysPath.join(__dirname, '../modules/SocketClientLoader.js?cacheId=' + cacheId)
309-
});
306+
if(project.server && project.server.overlay) {
307+
nextConfig.module.postLoaders.push({
308+
test: /\.(js)$/,
309+
loader: sysPath.join(__dirname, '../modules/SocketClientLoader.js?cacheId=' + cacheId)
310+
});
311+
}
310312

311313
if(shouldCompileAllEntries) {
312314
return nextConfig;

src/models/Project.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ class Project {
9494
this.proxy = proxy || [];
9595
}
9696

97+
setServer(server) {
98+
this.server = server || {};
99+
}
100+
97101
readConfig() {
98102
if(!this.configFile) {
99103
// no local config, i.e., server command)
@@ -203,6 +207,7 @@ class Project {
203207
this.setCommands(ykitConfigFile.commands || ykitConfigFile.config.command); // 后者兼容以前形式
204208
this.setHooks(ykitConfigFile.hooks);
205209
this.setProxy(ykitConfigFile.proxy);
210+
this.setServer(ykitConfigFile.server);
206211
} else {
207212
logError('Local ' + this.configFile + ' config not found.');
208213
logDoc('http://ued.qunar.com/ykit/docs-配置.html');

0 commit comments

Comments
 (0)