Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created May 7, 2012 20:31
Show Gist options
  • Save pamelafox/2630204 to your computer and use it in GitHub Desktop.
Save pamelafox/2630204 to your computer and use it in GitHub Desktop.
Grunt for a CSS/JS WebApp
/*global module:false*/
module.exports = function(grunt) {
var CSS_DIR = 'src/css/';
var JS_DIR = 'src/js/';
var BUILD_DIR = '../build/';
// Project configuration.
grunt.initConfig({
lint: {
files: [JS_DIR + 'app/**/*.js']
},
less: {
css: {
src: [CSS_DIR + 'less/base.less'],
dest: CSS_DIR + 'base.css',
}
},
concat: {
css: {
src: [CSS_DIR + 'libs/*.css', CSS_DIR + 'app/*.css'],
dest: BUILD_DIR + 'css/editor.css'
},
js: {
src: [JS_DIR + 'libs/bootstrap.js', JS_DIR + 'libs/closure-all.js', JS_DIR + 'app/*.js'],
dest: BUILD_DIR + 'js/editor.js'
},
},
min: {
js: {
src: '<config:concat.js.dest>',
dest: BUILD_DIR + 'js/editor-min.js'
}
},
cssmin: {
css: {
src: '<config:concat.css.dest>',
dest: BUILD_DIR + 'css/editor-min.css'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {'goog': true}
},
uglify: {}
});
grunt.loadNpmTasks('/usr/local/lib/node_modules/grunt-less');
grunt.loadNpmTasks('/usr/local/lib/node_modules/grunt-css');
// Default task.
grunt.registerTask('default', 'less concat min cssmin');
};
@cowboy
Copy link

cowboy commented May 7, 2012

You could install the grunt-less and grunt-css plugins locally using npm install without the -g option. Or add them into a project-specific npm package.json file and then just run npm install to initialize your project.

Then, you could just do this, because they'd be installed locally:

grunt.loadNpmTasks('grunt-less');
grunt.loadNpmTasks('grunt-css');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment