In an older version of cssmin it was possible to create to different target files. I minified a style.min.css and an above-the-fold.min.css. Now I updated to a newer version of nodejs, npm, grunt and cssmin and it is not possible to minify to different outputfiles anymore. Since the update grunt only minifies the second task and skip the first task. Do you have a hint for me to minify both tasks?
cssmin: {
options: {
mergeIntoShorthands: false,
roundingPrecision: -1
},
target: {
files: {
'data/style.min.css': ['a.css', 'b.css', 'c.css', 'd.css', 'e.css', 'f.css', 'g.css']
}
}
},
penthouse: {
extract : {
outfile : 'data/above-the-fold.temp.css',
css : './data/style.min.css',
url : 'http://localhost/',
width : 1280,
height : 500
},
},
cssmin: {
options: {
mergeIntoShorthands: false,
roundingPrecision: -1
},
target: {
files: {
'data/above-the-fold.min.css': ['data/above-the-fold.temp.css']
}
}
}
grunt-contrib-cssmin will allow multiple Targets to be defined in a single Task. For example:
Gruntfile.js
Each Target name should be unique within the
cssmin
Task. For example:targetA
andtargetB
As you've included the
penthouse
Task in your post, I guess that you need to run that after generating thestyle.min.css
file, and before generating theabove-the-fold.min.css
. To do this you can register your Tasks as follows:Note: The use of the semi-colon notation, namely
cssmin:targetA
andcssmin:targetB
. This simply ensures thattargetA
of thecssmin
Task is run before thepenthouse
Task. Subsequently, (when thepenthouse
Task completes),targetB
of thecssmin
Task is run.