Leone
Leone

Reputation: 3418

How to embed rollup bundle js content in HTML

I am using rollup to bundle a simple javascript application using iife format. But I wanted to embed the bundled javascript content inside an HTML file and couldn't find the right plugin to do that.

I am not looking for ways of embedding a script tag which points to the bundle javascript file ... but rather ways of embedding the bundle content inside an html file.

Not looking for: (which is possible using plugins)

<script src="bundle.js"></script>

Looking for:

<script>
    // actual bundle content (JavaScript code) here
</script>

Upvotes: 5

Views: 1900

Answers (1)

Leone
Leone

Reputation: 3418

Since I wasn't able to find any solution, I forked the rollup-plugin-generate-html-template plugin and added the feature. Setting embedContent: true in the plugin options will suffice.

  • The original plugin repository: here
  • My fork: here

Upvotes: 6

Related Questions