node-version-assets
node-version-assets copied to clipboard
An options for specifing file name in code to replace
hi,
I would like to be able to tell the name of the file to replace version number in my html who do not match the name on the filesystem.
the reason is that I create the file name from a variable. so in my html the tag (using EJS) is like
<link rel="stylesheet" href="/release/<%=shortname%>.min.css" type="text/css">
<script src="/release/<%=shortname%>.min.js"></script>
and I use the same variable to create the path name I send to node-version-assets (via grunt)
like "public/release/" + shortName + ".min.js"
the file real name is defined by the variable.
Is there a ways to achieve this?
thank you
Yes it could work but you'd need to share the variable value somehow, eg define it in a JSON file and include that before running the grunt script and EJS.
I already do that,
The problem is to tell "node-version-assets" to version files named mycoolwebsite.min.js and mycoolwebsite.min.css and to change it's name in my ejs where it is writed as "<%=shortname%>.min.js" and "<%=shortname%>.min.css".
how can I specify two different name, one for the real file and one for the file as writed in the ejs?
You'd need to write the output of the renaming into a JSON file and then feed that to your EJS template. Currently the file renames are just written to stdout, see: https://github.com/techjacker/node-version-assets/blob/master/lib/main.js#L242