Tommz Tommz - 10 months ago 62
Javascript Question

Grunt htmlmin errors

I'm using

plugin. This is how my
looks like:

module.exports = function(grunt) {

pkg: grunt.file.readJSON('package.json'),

htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
files: {
'/views/build/404.html': '/view/src/404.html'


grunt.registerTask('default', ['htmlmin']);

Nothing special, really. My 404.html is also pretty simple, but even on simpler
files, grunt doesn't work. For example, let's say take following


It doesn't even work on that. What I get as a result in console is:

Running "htmlmin:dist" (htmlmin) task
Minified 0 files (1 failed)

Done, without errors.

Where can I see why it failed?

I tried really many things like removing
and I also tried changing
structure where I ended up with this:

files: {
expand: true,
cwd: 'views/src/',
src: '404.html',
build: 'views/build/404.html'

But that doesn't work either and error that I'm getting now is this:

Running "htmlmin:dist" (htmlmin) task
Warning: pattern.indexOf is not a function Use --force to continue.

Aborted due to warnings.

What am I doing wrong?

Answer Source

I don't know the actual reason for the error. But modifying the source by adding square brackes, as below, worked for me.

files: [{
    expand: true,
    cwd: 'views/src/',
    src: '404.html',
    build: 'views/build/404.html'