Skip to content

Instantly share code, notes, and snippets.

@GitaiQAQ
Created September 2, 2020 12:44
Show Gist options
  • Select an option

  • Save GitaiQAQ/87fb40030aafa73b8debc8a58cf0477f to your computer and use it in GitHub Desktop.

Select an option

Save GitaiQAQ/87fb40030aafa73b8debc8a58cf0477f to your computer and use it in GitHub Desktop.
{
name: 'InlineScriptHTMLRender',
async generateBundle(_, bundles, isWrite) {
if (isWrite) {
return new Promise((resolve) => {
Object.values(bundles).map((bundle) => {
Object.keys(bundles).map(key => delete bundles[key]);
if (bundle.name === 'bootloader') {
renderFile('src/index.ejs', {
inlineScript: bundle.code,
}, {
rmWhitespace: true,
}, (err, source) => {
if (err) throw err;
this.emitFile({
type: 'asset',
source,
name: 'Rollup HTML Asset',
fileName: 'index.html',
});
resolve();
});
}
});
});
}
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment