Skip to content

Instantly share code, notes, and snippets.

@jreiher2003
Created October 14, 2015 20:35
Show Gist options
  • Save jreiher2003/f2c7273613dc137828c2 to your computer and use it in GitHub Desktop.
Save jreiher2003/f2c7273613dc137828c2 to your computer and use it in GitHub Desktop.
Starter grunt file for watching over dev files and updating production files
// Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
// get the configuration info from package.json ----------------------------
// this way we can use things like name and version (pkg.name)
pkg: grunt.file.readJSON('package.json'),
// configure jshint to validate js files -----------------------------------
jshint: {
options: {
reporter: require('jshint-stylish') // use jshint-stylish to make our errors look and read good
},
// when this task is run, lint the Gruntfile and all js files in src
build: ['Grunfile.js', 'static/**/*.js']
},
uglify: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},
build: {
files: {
//concats and minify's
'static/dist/js/main.min.js': ['static/js/main.js']
}
}
},
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n'
},
build: {
files: {
'static/dist/css/styles.min.css': ['static/css/styles.css']
}
}
},
watch: {
files: ['static/css/*.css', 'static/js/*.js'],
tasks: ['default']
}
});
// ===========================================================================
// LOAD GRUNT PLUGINS ========================================================
// ===========================================================================
// we can only load these if they are in our package.json
// make sure you have run npm install so our app can find these
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['jshint', 'uglify', 'cssmin']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment