Thomas Andersen
Thomas Andersen

Reputation: 1529

How do we set a target in a grunt cssmin task?

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:

Upvotes: 5

Views: 13140

Answers (1)

Kyle Robinson Young
Kyle Robinson Young

Reputation: 13762

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.

Upvotes: 16

Related Questions