Insert assets such as .js, .css into an HTML file.
Insert assets such as scripts, stylesheets and shortcut icons into HTML.
Supports stamping of asset URLs, preloading assets and more fine grained options for specific asset types.
``bash
--html
the HTML template to insert assets into
--out
the output HTML file path
`
`bash`
--scripts [--async] [--module] [--nomodule] [--attr name=value]
Add
`
If the --out file is in a separate directory, URLs are relative to that directory
`bash`
html-insert-assets
--html ./index.tmpl.html
--out ./sub/index.html
--scripts ./a.js b.js sub/c.js
will insert:
`html`
Root asset directories to trim and convert to URLs relative to the the --out directory
`bash`
html-insert-assets
--html ./index.tmpl.html
--out ./index.html
--roots .
--scripts ./a.js b.js sub/c.js
will insert:
`html`
Root directories of assets (multiple):
`bash`
html-insert-assets
--html ./index.tmpl.html
--out ./index.html
--roots sub /abs/path
--scripts /abs/path/a.js b.js sub/c.js
will insert:
`html`
Root directories of assets (multiple + alternate --out):
`bash`
html-insert-assets
--html ./index.tmpl.html
--out ./out/index.html
--roots sub /abs/path
--scripts /abs/path/a.js b.js sub/c.js
will insert:
`html`
Absolute paths outside any root directories:
`bash`
html-insert-assets
--html ./index.tmpl.html
--out sub/index.html
--roots sub /abs/path
--scripts /path/to/my.js
will insert:
`html`
Scripts, auto detecting type="module" vs nomodule
`bash`
html-insert-assets
--html ... --out ...
--scripts foo.mjs foo.js
Scripts, manually specifying type="module" vs nomodule
`bash`
html-insert-assets
--html ... --out ...
--scripts --module app.mjs
--scripts --nomodule app-legacy.js
Multiple favicons:
`bash`
html-insert-assets
--html ... --out ...
--favicon --sizes=16x16 default.ico
--favicon --sizes=128x128 large.png
Stylesheets:
`bash`
html-insert-assets
--html ... --out ...
--stylesheets main.css
--stylesheets --media=print print-only.css
Preloading some .js and .jpg files.
`bash`
html-insert-assets
--html ./index.tmpl.html
--out ./index.html
--preload load-later.js large-image.jpg
will insert:
`html``
Originally forked from rules_nodejs.