Created
April 9, 2013 13:44
-
-
Save mattbanks/5345780 to your computer and use it in GitHub Desktop.
Gruntfile.js where JS is not soft refreshing with LiveReload - getting a hard refresh for JS changes in the compiled *.min.js files after run through uglify
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: { | |
compass: { | |
files: ['assets/scss/**/*.{scss,sass}'], | |
tasks: ['compass'] | |
}, | |
js: { | |
files: '<%= jshint.all %>', | |
tasks: ['jshint', 'uglify'] | |
}, | |
livereload: { | |
files: [ | |
'*.css', | |
'assets/js/*.js', | |
'*.html', | |
'*.php', | |
'assets/images/**/*.{png,jpg,jpeg,gif,webp,svg}' | |
], | |
tasks: ['livereload'] | |
} | |
}, | |
// compass and scss | |
compass: { | |
dist: { | |
options: { | |
config: 'config.rb', | |
force: true | |
} | |
} | |
}, | |
// javascript linting with jshint | |
jshint: { | |
options: { | |
jshintrc: '.jshintrc', | |
"force": true | |
}, | |
all: [ | |
'Gruntfile.js', | |
'assets/js/source/**/*.js' | |
] | |
}, | |
// uglify to concat, minify, and make source maps | |
uglify: { | |
dist: { | |
options: { | |
sourceMap: 'assets/js/map/source-map.js' | |
}, | |
files: { | |
'assets/js/plugins.min.js': [ | |
'assets/js/source/plugins.js', | |
'assets/js/vendor/**/*.js', | |
'!assets/js/vendor/modernizr*.js' | |
], | |
'assets/js/main.min.js': [ | |
'assets/js/source/main.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: "[email protected]", | |
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: "[email protected]", | |
recursive: true, | |
syncDest: true, | |
exclude: '<%= rsync.staging.exclude %>' | |
} | |
} | |
}); | |
// rename tasks | |
grunt.renameTask('regarde', 'watch'); | |
grunt.renameTask('rsync', 'deploy'); | |
// register task | |
grunt.registerTask('default', [ | |
'livereload-start', | |
'watch' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment