srod/node-minify

Folder minification gets empty file name

abemail1 opened this issue · 2 comments

Given the file below having the intention to minify all HTML files in the given folder and write out individual minified files:

var comp = require('node-minify');

comp.minify({
  compressor: 'html-minifier',
  input: 'in/*.html',
  output: 'out/$1.min.html',
  callback: function(err, min) {
    if (err) console.log(err);
    console.log(min);
  }
});

...the file name that results is '.min.html'. Seems like $1 resolves to empty. $0 and $2 appear literally so $1 is processed but it is empty.

Any idea what the issue might be?

srod commented

It should work with latest version of node-minify, can you update to it?
You have to: npm install @node-minify/core @node-minify/html-minifier
And then:

var comp = require('@node-minify/core');
var htmlMinifier = require('@node-minify/html-minifier');

comp({
  compressor: htmlMinifier,
  input: 'in/*.html',
  output: 'out/$1.min.html',
  callback: function(err, min) {
    if (err) console.log(err);
    console.log(min);
  }
});

@srod that worked perfectly. Thank you.