st-bundle
Version:
CLI for watching and bundling SpringType projects.
26 lines (25 loc) • 895 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Bundle_1 = require("../bundle/Bundle");
async function addServerEntry(ctx, bundles) {
const serverEntry = new Bundle_1.Bundle({
ctx,
name: '_server_entry',
priority: -1,
type: Bundle_1.BundleType.SERVER_ENTRY,
webIndexed: false,
skipHash: true,
});
if (ctx.config.sourceMap.project) {
serverEntry.addContent(`require('source-map-support').install();`);
}
const sorted = bundles.sort((a, b) => a.bundle.props.priority - b.bundle.props.priority);
sorted.forEach(bundle => {
if (bundle.bundle.props.webIndexed) {
serverEntry.addContent(`require("./${bundle.stat.localPath}")`);
}
});
const info = await serverEntry.generate().write();
return { info };
}
exports.addServerEntry = addServerEntry;