Last active
August 29, 2015 14:20
-
-
Save joshdcomp/c93741bf30981ff71b87 to your computer and use it in GitHub Desktop.
Super generic grunt file/setup for less
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
// This was set up using the help of this tut: | |
//http://merrickchristensen.com/articles/gruntjs-workflow.html | |
module.exports = function(grunt) { | |
// grunt.loadNpmTasks('grunt-contrib-jshint'); // load lint | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
//watch for stuff when we save | |
watch: { | |
js: { | |
files: ['pre/js/**/*.js'], | |
tasks: ['concat:js'] | |
}, | |
less: { | |
files: ['pre/less/**/*.less', 'pre/less/*.less'], | |
tasks: ['less:dev'] | |
}, | |
}, | |
//set up concats | |
concat: { | |
options: { | |
// Get the filepath for all js files and format it to be a | |
// separator for easier debugging in concatted files | |
process: function(src, filepath){ | |
var lines = '\n//--------------------------------------------------\n' | |
var final_name = filepath.substring(filepath.lastIndexOf('/scripts/') + 1, filepath.length);//.join('-'); | |
return( lines | |
+ '// Source: ' | |
+ final_name | |
+ lines | |
+ src); | |
} | |
}, | |
js: { | |
src: [ | |
'path/to/speicific/file.js', | |
'path/to/all/files/*.js' | |
], | |
dest: 'path/to/destination.js', | |
nonull: true | |
},//js | |
}, | |
//set up sass | |
less: { | |
dev: { | |
files:{ | |
'path/to/compiled/css.css' : 'path/to/less/index.less' | |
} | |
}, | |
prod: { | |
options:{ | |
compress: true | |
}, | |
files: { | |
'path/to/compiled/css.css' : 'path/to/less/index.less' | |
} | |
} | |
},//sass | |
});//initConfig | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
//----------------------------------------------------------------------------- | |
//CUSTOM CLI COMMANDS | |
grunt.registerTask('default', 'Compiles less, concats js.', function(n) { | |
var tasklist = ['concat', 'less:dev']; | |
//watch should always be last | |
if(grunt.option('watch')) { | |
tasklist.push('watch') | |
} | |
grunt.task.run(tasklist); | |
}); | |
grunt.registerTask('js', 'Concats javascript files, pass --watch to...watch the files', function(n){ | |
var tasklist = ['concat:js']; | |
//watch should always be last | |
if(grunt.option('watch')) { | |
tasklist.push('watch:js'); | |
} | |
grunt.task.run(tasklist); | |
}); | |
grunt.registerTask('css', 'Compiles less to css, pass --watch to...watch the files', function(n){ | |
var tasklist = ['less:dev']; | |
if(grunt.option('ie')) { | |
tasklist.push('less:ie'); | |
} | |
//Watch should always be last | |
if(grunt.option('watch')) { | |
tasklist.push('watch:less'); | |
} | |
grunt.task.run(tasklist); | |
}); | |
grunt.registerTask('prod', 'Compiles less to compressed css, uglifies javascript', function(n){ | |
var tasklist = ['concat:prod', 'uglify:prod', 'less:prod']; | |
}); | |
}; |
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
{ | |
"name": "oticon", | |
"description": "Grunt tasks for oticon", | |
"version": "0.1.1", | |
"author": "[name]", | |
"homepage": "[url]", | |
"dependencies": { | |
"grunt": "*", | |
"grunt-contrib-watch": "*", | |
"grunt-contrib-concat": "*", | |
"grunt-contrib-less": "*", | |
}, | |
"engine": "node *" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment