All Projects → bengsfort → rollup-plugin-generate-html-template

bengsfort / rollup-plugin-generate-html-template

Licence: MIT License
Rollup plugin for automatically injecting a script tag with the final bundle into an html file.

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to rollup-plugin-generate-html-template

rollup-plugin-purs
Bundles PureScript modules with Rollup
Stars: ✭ 71 (+22.41%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-lit-css
Moved to https://github.com/bennypowers/lit-css
Stars: ✭ 35 (-39.66%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-inject-process-env
Inject environment variables in process.env with Rollup
Stars: ✭ 48 (-17.24%)
Mutual labels:  rollup, rollup-plugin
postcss-font-grabber
A postcss plugin, it grabs remote font files and update your CSS, just like that.
Stars: ✭ 26 (-55.17%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-tagged-template
Use plain HTML files as tagged templates.
Stars: ✭ 24 (-58.62%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-userscript-metablock
Transform json file to userscript metablock and append on.
Stars: ✭ 26 (-55.17%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-html
Import HTML files as strings in rollup build
Stars: ✭ 36 (-37.93%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-closure-compiler-js
Rollup plugin for optimizing JavaScript with google-closure-compiler-js.
Stars: ✭ 31 (-46.55%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-sizes
Rollup plugin to display bundle contents & size information
Stars: ✭ 77 (+32.76%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-external-globals
Transform external imports into global variables like output.globals.
Stars: ✭ 57 (-1.72%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-generate-package-json
Generate package.json file with packages from your bundle using Rollup
Stars: ✭ 29 (-50%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-markdown
import JavaScript from Markdown code blocks
Stars: ✭ 16 (-72.41%)
Mutual labels:  rollup, rollup-plugin
web-config
A Rollup configuration to build modern web applications with sweet features as for example SCSS imports, Service Worker generation with Workbox, Karma testing, live reloading, coping resources, chunking, treeshaking, Typescript, license extraction, filesize visualizer, JSON import, budgets, build progress, minifying and compression with brotli a…
Stars: ✭ 17 (-70.69%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-collect-sass
Collect Sass, then compile
Stars: ✭ 17 (-70.69%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-jscc
Conditional compilation and compile-time variable replacement for Rollup
Stars: ✭ 52 (-10.34%)
Mutual labels:  rollup, rollup-plugin
rollup-plugin-swc
Rollup plugin to compile bundles with the SWC.
Stars: ✭ 59 (+1.72%)
Mutual labels:  rollup
rollup-plugin-istanbul
Seamless integration between Rollup and Istanbul
Stars: ✭ 39 (-32.76%)
Mutual labels:  rollup
vite-rollup-plugins
A compatibility list of rollup plugins for Vite 2 and test playground
Stars: ✭ 76 (+31.03%)
Mutual labels:  rollup-plugin
r1cs-tutorial
Tutorial for writing constraints in the `arkworks` framework
Stars: ✭ 74 (+27.59%)
Mutual labels:  rollup
stan
🔨 Collection of front-end engineering tools
Stars: ✭ 19 (-67.24%)
Mutual labels:  rollup

rollup-plugin-generate-html-template

build status npm version code coverage

Auto-inject the resulting rollup bundle via script and link tags into an HTML template.

Installation

npm install --save-dev rollup-plugin-generate-html-template

Usage

// rollup.config.js
import htmlTemplate from 'rollup-plugin-generate-html-template';

export default {
  entry: 'src/index.js',
  dest: 'dist/js/bundle.js',
  plugins: [
    htmlTemplate({
      template: 'src/template.html',
      target: 'index.html',
    }),
  ],
};

On final bundle generation the provided template file will have a script tag injected directly above the closing body tag with a link to the js bundle and similarly a link tag above the closing head to the css bundle. By default it uses the same file name and places it directly next to the JS bundle.

<!-- src/index.html -->
<html>
  <head>
    <title>Example</title>
  <head>
<body>
  <canvas id="main"></canvas>
</body>
</html>

<!-- dist/index.html -->
<html>
  <head>
    <title>Example</title>
    <link rel="stylesheet" type="text/css" href="bundle.css">
  <head>
<body>
  <canvas id="main"></canvas>
  <script src="bundle.js"></script>
</body>
</html>

Options

  • template: (required) The path to the source template.
  • target: The directory and file name to use for the html file generated with the bundle.
  • attrs: The attributes provided to the generated bundle script tag. Passed as an array of strings Example: attrs: ['async', 'defer] will generate <script async defer src="bundle.js"></script>
  • replaceVars: An object containing variables that will be replaced in the generated html. Example: replaceVars: { '__CDN_URL__': process.env.NODE_ENV === 'production' ? 'https://mycdn.com' : '' } will replace all instances of __CDN_URL__ with http://mycdn.com if the environment is production

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].