Skip to content

Insert assets such as .js, .css into an HTML file.

License

Notifications You must be signed in to change notification settings

alan-agius4/html-insert-assets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

html-insert-assets

Insert assets such as .js, .css into an HTML file.

  • .js files inserted at end of
  • .css files inserted at end of
  • .ico file inserted at end of

Examples

Examples of functionality shared across asset types use .js for simplicity.

Basic relative paths:

html-insert-assets
    --html ./index.tmpl.html
    --out ./index.html
    --assets ./a.js b.js sub/c.js

will insert:

<script src="./a.js"></script>
<script src="./b.js"></script>
<script src="./sub/c.js"></script>

If the --out file is in a separate directory, URLs are relative to that directory

html-insert-assets
    --html ./index.tmpl.html
    --out ./sub/index.html
    --assets ./a.js b.js sub/c.js

will insert:

<script src="../a.js"></script>
<script src="../b.js"></script>
<script src="./c.js"></script>

Root asset directories to trim and use absolute URLs

html-insert-assets
    --html ./index.tmpl.html
    --out ./index.html
    --root .
    --assets ./a.js b.js sub/c.js

will insert:

<script src="/a.js"></script>
<script src="/b.js"></script>
<script src="/sub/c.js"></script>

Root directories of assets (multiple):

html-insert-assets
    --html ./index.tmpl.html
    --out ./index.html
    --root sub /abs/path
    --assets /abs/path/a.js b.js sub/c.js

will insert:

<script src="/a.js"></script>
<script src="./b.js"></script>
<script src="/c.js"></script>

Root directories of assets (multiple + alternate --out):

html-insert-assets
    --html ./index.tmpl.html
    --out ./out/index.html
    --root sub /abs/path
    --assets /abs/path/a.js b.js sub/c.js

will insert:

<script src="/a.js"></script>
<script src="../b.js"></script>
<script src="/c.js"></script>

Notes

Originally forked from https://github.com/bazelbuild/rules_nodejs/tree/0.41.0/packages/inject-html.

About

Insert assets such as .js, .css into an HTML file.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%