Reputation: 4244
I have been developing on the front end for years but I am finally making the move towards developing using Grunt and moving away from tools like Prepros and Koala for my Sass compilation.
My main question is, how do I force my grunt tasks to remove all comments from the compiled and minified CSS generated from my SASS files?
Currently I have the following gruntfile.js file snippet setup but this only removes single line comments. I want all of my compiled css to be in one big line with no spacing and no comments:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist:{
files: {
'css/main.css' : 'css/main.scss'
},
options: {
style: 'compressed'
}
}
}
})
Any help would be greatly appreciated.
Upvotes: 2
Views: 2230
Reputation: 10228
Not sure that grunt-sass plugin can do this job, but grunt-contrib-cssmin yes.
Set keepSpecialComments
option to 0
to remove all comments.
From cleancss documentation :
keepSpecialComments -
*
for keeping all (default),1
for keeping first one only,0
for removing all
Simple example :
cssmin: {
options: {
keepSpecialComments: 0
},
target: {
files: {
'output.css': ['foo.css', 'bar.css']
}
}
}
Upvotes: 1