hardcode
hardcode
assembles a virtual, import
-able file system from disk.
Install
npm i hardcode
CLI
The package comes with a built-in CLI for build scripts:
hardcode <glob> --out <out> --prefix <prefix>
See hardcode --help
for more details.
Add hardcode <glob>
to your build script. For example:
...
"build": "hardcode <pattern> && jest"
...
Usage
- Imagine that you have the following files on disk:
templates/
dev/
email.html
res/
style.css
- Now, run
hardcode
on thetemplates/dev
directory.
const hardcode = ; ;
- Finally, import the
templates/dev
directory as a JSON object:
const templates = const html = templates'email.html' // email.html file contentsconst css = templates'res''style.css' // style.css file contents
License
This code is licensed under GNU-GPLv3.