A command line utility to inject css and js files into an html file or to remove code based on conditions.
npm install metainject2html
Home
`
The css and javascript files will be injected between the markers and the scripts and stylesheets that are already there will be removed.
This way you can replace the regular files used in a development environment with the built files (bundled, minified, versioned) in a production environment.
Options:
-h, --help output usage information
-V, --version output the version number
-i, --input Input file
-o, --output `
-- dist
-- css
styles.1234abc.css
-- js
vendor.js
build.4567def.js
`
metainject2 -i index.html -o dist/index.html -c dist/css -j dist/js -r production -H
will result in the file dist/index.html:
`html
Home
`
Notice that the code
`
`
has been removed.
The comment
`
`
has been replaced by the git hash of the current commit.
Specifying a single file instead of a directory will only inject that single file:
metainject2 -i index.html -o dist/index.html -c dist/css -j dist/js/build.4567def.js -r production
results in:
`html
Home
`
Notice that vendor.js is not injected.
$3
Run npm test` to run the tests.