5

I am trying out cssmin for Grunt

According to the docs targets can be defined "according to the grunt Configuring tasks guide." When I create a cssmin task using that pattern, like:

cssmin: {
  my_target: {
    minify: {
      src: 'path-to/default.css',
      dest: 'path-to/default.min.css'
    }
  }
}

the minified file is not created.

If I remove the target level it works as expected. Do I do something wrong here? or are there other options than cssmin (In my research I picked this as everybody was pointing to it)

Using:

  • grunt v0.4.1
  • cssmin v0.6.0
Kas Elvirov
  • 7,394
  • 4
  • 40
  • 62
Thomas Andersen
  • 1,501
  • 5
  • 18
  • 23

1 Answers1

16

Your configuration is just a little off. minify is also just a target name. Do this instead:

cssmin: {
  minify: {
    src: 'path-to/default.css',
    dest: 'path-to/default.min.css'
  }
}

OR

cssmin: {
  my_target: {
    src: 'path-to/default.css',
    dest: 'path-to/default.min.css'
  }
}

Please read http://gruntjs.com/configuring-tasks on how to configure tasks.

Kyle Robinson Young
  • 13,732
  • 1
  • 47
  • 38
  • 1
    Thanks! The second example was what I was looking for. It looks like cssmin uses a slightly different pattern than other Grunt tasks – Thomas Andersen May 24 '13 at 08:40
  • All the contrib tasks use `this.files` so you're able to use any of the config patterns listed in the docs: http://gruntjs.com/configuring-tasks – Kyle Robinson Young May 24 '13 at 17:13