Created
October 14, 2015 20:35
-
-
Save jreiher2003/f2c7273613dc137828c2 to your computer and use it in GitHub Desktop.
Starter grunt file for watching over dev files and updating production files
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
// 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