breezewish / express-minify

Automatically minify and cache your javascript and css files.
https://npmjs.org/package/express-minify
MIT License
86 stars 18 forks source link

js_match.test is not a function #50

Closed physicalit closed 7 years ago

physicalit commented 7 years ago

Hello,

I've just configured express-minify an i get the following error:

Express server listening on port 3001
/foo/node_modules/express-minify/index.js:66
      } else if (js_match.test(contentType)) {
                          ^

TypeError: js_match.test is not a function

My conf is:


var minify = require('express-minify');
var myUglifyJS = require('uglify-js');
var myCssmin = require('cssmin');

app.use(cookieParser());
app.use(compress());
app.use(minify({
    uglifyJS: myUglifyJS,
    cssmin: myCssmin,
    js_match: config.root + '/public/js/',
    css_match: config.root + '/public/css/',
  }));

I believe to be a bug with express-minify, but i'm also new to js, so i might not be right.

Thanks!

breezewish commented 7 years ago

Hi, you need to specify a regular expression for js_match and css_match. In addition, those two options (including other xxx_match as well) match content-types instead of URLs and by default it will minify any URLs ended with .js or .css.