direct input
Opened this issue · 3 comments
Deleted user commented
Is there a way to put in css or javascript code directly?
I have some stuff that is generated on the fly and not saved to files, is there a way to add it to the input somehow?
srod commented
Yes, you can use "in memory" feature: https://node-minify.2clics.net/getting-started.html#in-memory
Deleted user commented
Oh, thank you.
No idea how i missed that :)
Deleted user commented
Since input and content cannot be combined, my solution here is:
const minify = require('@node-minify/core');
const noCompress = require('@node-minify/no-compress');
const fs = require('fs-extra');
minify({
compressor: noCompress,
input: input,
output: '/dev/null',
callback: (error, content) => {
content += `
APP_VERSION = `+SERVER_VERSION+`;
`;
fs.outputFile(this.bundle_dir + 'bundle.js', content);
}
});
This will only work if one wants to prepend or append stuff. To inject code between the input array files a hack of utils.getContentFromFiles would be the fastest solution I guess.