Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin hook that is called once for all outputs #3536

Open
dilyanpalauzov opened this issue May 5, 2020 · 2 comments
Open

Add plugin hook that is called once for all outputs #3536

dilyanpalauzov opened this issue May 5, 2020 · 2 comments

Comments

@dilyanpalauzov
Copy link

With rollup for the same input I generate two outputs: ES and UMD. I want to tweak @rollup/plugin-html to generate a single index.html containg

<script type='module' src='es/x.js'></script>
<script nomodule src='und/x.js'></script>

As far as I can see the writeBundle and generateBundle hooks are called per output, when output is an array. But the index.html file has to be generated only once for all outputs, so it shall have a hook that is called at the very end.

@lukastaegert
Copy link
Member

That is architecturally difficult as plugin hooks are managed by Rollup core, but Rollup core just cannot know how many outputs there will be. It is a problem of the JavaScript API that allows to create an infinite amount of outputs per bundle. So there will be no easy solution. Technically each bundle creates its own directory anyway so the file would live outside the bundling process anyway.
You could try some trickery by using output plugins: If you give each output you want to include a specific output plugin, you could be counting plugin instances and create the file when the last was created.

@seivan
Copy link

seivan commented May 8, 2020

Yeah kinda also need this, for every script tag loop over in the template an add both nomodule and module versions of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants