Created
March 25, 2014 03:55
-
-
Save thpoiani/9755004 to your computer and use it in GitHub Desktop.
Concat normalize.css in css files using Grunt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gruntfile loading external tasks | |
* | |
* ./Gruntfile.js | |
* | |
* @param grunt | |
* @author Thiago Poiani <[email protected]> | |
*/ | |
module.exports = function (grunt) { | |
'use strict'; | |
// load tasks directory | |
grunt.loadTasks('grunt_tasks'); | |
grunt.registerTask('default', ['normalize-concat']); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Task for concat normalize.css in all css files inside the directory ./css | |
* | |
* ./grunt_tasks/normalize-concat.js | |
* | |
* @param grunt | |
* @author Thiago Poiani <[email protected]> | |
*/ | |
module.exports = function (grunt) { | |
'use strict'; | |
var normalize, css, files, name, concat; | |
// normalize.css path | |
// bower install normalize.css --save | |
normalize = './bower_components/normalize.css/normalize.css'; | |
// css files path | |
css = './css/'; | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.registerTask('normalize-concat', function () { | |
// all .css files | |
files = grunt.file.expand(css + '*.css'); | |
files.forEach(function (file) { | |
// css file name | |
name = file.replace(css, ''); | |
concat = grunt.config.get('concat') || {}; | |
concat[name] = { | |
src: [normalize, file], | |
dest: file | |
}; | |
grunt.config.set('concat', concat); | |
}); | |
grunt.task.run('concat'); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment