-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (34 loc) · 1.04 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const path = require('path');
const fs = require('fs');
module.exports = app => {
app.use(function* (next) {
if (app.webpack_build_success) {
yield* next;
} else {
if (app.webpack_loading_text) {
this.body = app.webpack_loading_text;
} else {
const filePath = path.resolve(__dirname, './lib/template/loading.html');
this.body = app.webpack_loading_text = fs.readFileSync(filePath, 'utf8');
}
}
});
if (app.view) {
app.view.resolve = function(name) {
return Promise.resolve(name);
};
}
app.messenger.on('webpack_success', data => {
if (app.vue && data) {
const renderBundle = app.vue.renderBundle;
const { bundle, renderOptions } = data;
app.webpack_build_success = true;
app.vue.bundleCache = false;
app.vue.renderOptions = {...app.vue.renderOptions, ...renderOptions};
app.vue.renderBundle = (name, context, options) => {
return renderBundle.bind(app.vue)(bundle, context, options);
};
}
});
};