...
|
...
|
@@ -10,6 +10,17 @@ module.exports = (app) => { |
|
|
function getStatic(path, def) {
|
|
|
return _.get(manifest, path, `${config.assetUrl}${def}`);
|
|
|
}
|
|
|
|
|
|
function getPreloads(list, type) {
|
|
|
let _list = [];
|
|
|
|
|
|
_.forEach(list, url => {
|
|
|
_list.push({url, type});
|
|
|
});
|
|
|
|
|
|
return _list;
|
|
|
}
|
|
|
|
|
|
return (req, res, next) => {
|
|
|
res.on('beforeRender', (params) => {
|
|
|
if (params) {
|
...
|
...
|
@@ -35,7 +46,10 @@ module.exports = (app) => { |
|
|
} else {
|
|
|
statics.styles.push(getStatic('common.index.css', 'css/index.css'));
|
|
|
}
|
|
|
|
|
|
res.locals.statics = statics;
|
|
|
res.locals.preloads = _.concat(getPreloads(statics.styles, 'style'),
|
|
|
getPreloads(statics.javascripts, 'script'));
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
|