grunt-usemin
grunt-usemin copied to clipboard
Document the :generated subtask.
It would have saved me hours of trouble if I had known that I could have just used the :generated subtask for uglify and cssmin. This allows me to have as many subtasks for each of these tasks that I want, but still use the expected behaviour from usemin whenever I want as well.
/* in grunt.initConfig */
cssmin: {
options: {
keepSpecialComments: 0
},
css: {
expand: true,
cwd: 'public/css/',
src: ['main.css', '!*.min.css'],
dest: 'public/css/',
ext: '.min.css',
options: {
keepSpecialComments: 0
}
}
},
});
grunt.registerTask('css', ['less:css','concat:css','cssmin:css']);
grunt.registerTask('build', [
'clean:dist',
'useminPrepare',
'imagemin:dist',
'less',
'concat',
'copy:dist',
'uglify:generated', // http://i.imgur.com/DgtYV.gif
'cssmin:generated', // http://i.imgur.com/DgtYV.gif
'rev',
'usemin',
'htmlmin',
'clean:post'
]);
Running grunt build
will now execute the expected cssmin task via usemin. If I had tried using just cssmin or cssmin:dist instead of cssmin:generated it would no longer run the usemin task.
@jdfm I've lost hours too with generated
tasks.