Last active
August 29, 2015 14:01
-
-
Save jfitzsimmons2/168a6957a7371c6d4900 to your computer and use it in GitHub Desktop.
Example grunt setup
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
'use strict'; | |
module.exports = function(grunt) { | |
// load all grunt tasks | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
grunt.initConfig({ | |
// watch for changes and trigger compass, jshint, uglify and livereload | |
watch: { | |
styles: { | |
files: ['src/styles/*.less'], | |
tasks: ['less'] | |
}, | |
js: { | |
files: ['src/scripts/*.js'], | |
tasks: ['jshint', 'uglify'] | |
}, | |
livereload: { | |
files: ['dest/assets/**'], | |
options: { | |
livereload: true | |
} | |
} | |
}, | |
// javascript linting with jshint | |
jshint: { | |
options: { | |
jshintrc: '.jshintrc', | |
"force": true | |
}, | |
all: [ | |
'Gruntfile.js', | |
'src/js/*.js' | |
] | |
}, | |
// less compiling | |
less: { | |
development: { | |
options: { | |
compress: true, | |
cleancss: true, | |
sourceMap: true, | |
sourceMapFilename: 'assets/styles/main.css.map', | |
sourceMapRootpath: '/sites/all/themes/oswego' //for drupal themes | |
}, | |
files: { | |
"assets/styles/main.css": "dev/styles/main.less" | |
} | |
} | |
}, | |
// uglify to concat, minify, and make source maps | |
uglify: { | |
options: { | |
beautify: false, | |
mangle: false | |
}, | |
scripts: { | |
files: { | |
'dest/assets/scripts/script.min.js': [ | |
'src/scripts/*.js' | |
] | |
} | |
} | |
} | |
// image optimization | |
// imagemin: { | |
// dist: { | |
// options: { | |
// optimizationLevel: 7, | |
// progressive: true | |
// }, | |
// files: [{ | |
// expand: true, | |
// cwd: 'assets/images/', | |
// src: '**/*', | |
// dest: 'assets/images/' | |
// }] | |
// } | |
// }, | |
// deploy via rsync | |
// deploy: { | |
// staging: { | |
// src: "./", | |
// dest: "~/path/to/theme", | |
// host: "user@host.com", | |
// recursive: true, | |
// syncDest: true, | |
// exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'README.md', 'config.rb', '.jshintrc'] | |
// }, | |
// production: { | |
// src: "./", | |
// dest: "~/path/to/theme", | |
// host: "user@host.com", | |
// recursive: true, | |
// syncDest: true, | |
// exclude: '<%= rsync.staging.exclude %>' | |
// } | |
// } | |
}); | |
// rename tasks | |
grunt.renameTask('rsync', 'deploy'); | |
// register task | |
grunt.registerTask('build', ['jshint', 'uglify', 'less']); | |
grunt.registerTask('default', ['build', 'watch']); | |
}; |
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": "project-name", | |
"version": "0.0.0", | |
"dependencies": {}, | |
"devDependencies": { | |
"grunt-contrib-copy": "^0.5.0", | |
"grunt-contrib-jshint": "^0.10.0", | |
"grunt-contrib-less": "^0.11.0", | |
"grunt-contrib-uglify": "^0.4.0", | |
"grunt-contrib-watch": "^0.6.1", | |
"grunt-rsync": "^0.5.0", | |
"matchdep": "^0.3.0" | |
}, | |
"engines": { | |
"node": ">=0.10.28" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment