Skip to content

Commit cd020af

Browse files
committed
Build/grunt: Extract css related tasks, use grunt-css instead
1 parent b2cca9a commit cd020af

2 files changed

Lines changed: 8 additions & 45 deletions

File tree

grunt.js

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function createBanner( files ) {
2121
" Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */";
2222
}
2323

24+
// a working grunt.loadNpmTasks replacement
25+
// gets us csslint and cssmin tasks
26+
require('grunt-css')(grunt);
27+
2428
// allow access from banner template
2529
global.stripDirectory = stripDirectory;
2630
grunt.registerHelper( "strip_all_banners", function( filepath ) {
@@ -91,7 +95,7 @@ grunt.initConfig({
9195
}
9296
},
9397
min: minify,
94-
css_min: minifyCSS,
98+
cssmin: minifyCSS,
9599
copy: {
96100
dist: {
97101
src: [
@@ -351,46 +355,6 @@ grunt.registerMultiTask( "zip", "Create a zip file for release", function() {
351355
});
352356
});
353357

354-
grunt.registerMultiTask( "csslint", "Lint CSS files with csslint", function() {
355-
var csslint = require( "csslint" ).CSSLint;
356-
var files = grunt.file.expandFiles( this.file.src );
357-
var ruleset = {};
358-
csslint.getRules().forEach(function( rule ) {
359-
ruleset[ rule.id ] = 1;
360-
});
361-
for ( var rule in this.data.rules ) {
362-
if ( !this.data.rules[ rule ] ) {
363-
delete ruleset[rule];
364-
} else {
365-
ruleset[ rule ] = this.data.rules[ rule ];
366-
}
367-
}
368-
var hadErrors = 0;
369-
files.forEach(function( filepath ) {
370-
grunt.log.writeln( "Linting " + filepath );
371-
var result = csslint.verify( grunt.file.read( filepath ), ruleset );
372-
result.messages.forEach(function( message ) {
373-
grunt.log.writeln( "[".red + ( "L" + message.line ).yellow + ":".red + ( "C" + message.col ).yellow + "]".red );
374-
log[ message.type === "error" ? "error" : "writeln" ]( message.message + " " + message.rule.desc + " (" + message.rule.id + ")" );
375-
});
376-
if ( result.messages.length ) {
377-
hadErrors += 1;
378-
}
379-
});
380-
if (hadErrors) {
381-
return false;
382-
}
383-
grunt.log.writeln( "Lint free" );
384-
});
385-
386-
grunt.registerMultiTask( "css_min", "Minify CSS files with Sqwish.", function() {
387-
var max = grunt.helper( "concat", grunt.file.expandFiles( this.file.src ) );
388-
var min = require( "sqwish" ).minify( max, false );
389-
grunt.file.write( this.file.dest, min );
390-
grunt.log.writeln( "File '" + this.file.dest + "' created." );
391-
grunt.helper( "min_max_info", min, max );
392-
});
393-
394358
grunt.registerMultiTask( "md5", "Create list of md5 hashes for CDN uploads", function() {
395359
// remove dest file before creating it, to make sure itself is not included
396360
if ( require( "path" ).existsSync( this.file.dest ) ) {
@@ -542,7 +506,7 @@ grunt.registerHelper( "lpad", function( str, len, chr ) {
542506

543507
grunt.registerTask( "default", "lint csslint qunit build compare_size" );
544508
grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" );
545-
grunt.registerTask( "build", "concat min css_min" );
509+
grunt.registerTask( "build", "concat min cssmin" );
546510
grunt.registerTask( "release", "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" );
547511
grunt.registerTask( "release_themes", "release download_themes copy_themes copy:themes md5:themes zip:themes" );
548512
grunt.registerTask( "release_cdn", "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" );

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
],
2727
"dependencies": {},
2828
"devDependencies": {
29-
"grunt": "0.2.x",
30-
"sqwish": "0.2.x",
29+
"grunt": "0.3.x",
30+
"grunt-css": "0.1.0",
3131
"request": "2.9.x",
32-
"csslint": "0.9.x",
3332
"adm-zip": "0.1.x",
3433
"rimraf": "2.0.1"
3534
},

0 commit comments

Comments
 (0)