srod/node-minify

direct input

Opened this issue · 3 comments

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?

Oh, thank you.
No idea how i missed that :)

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.