Skip to content

Instantly share code, notes, and snippets.

@jfitzsimmons2
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfitzsimmons2/168a6957a7371c6d4900 to your computer and use it in GitHub Desktop.
Save jfitzsimmons2/168a6957a7371c6d4900 to your computer and use it in GitHub Desktop.
Example grunt setup
'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']);
};
{
"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