Created
January 19, 2016 08:17
-
-
Save ders/3ca946b14641e5efe783 to your computer and use it in GitHub Desktop.
Build static assets with grunt.
This file contains hidden or 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
| module.exports = function(grunt) { | |
| grunt.initConfig({ | |
| uglify: { | |
| js: { | |
| files: { | |
| // These are all of js files we want minified and combined. | |
| 'pub/main.js': ['src/js/main.js'], | |
| 'pub/eggs.js': ['src/js/eggs.js', 'src/js/milk.js'], | |
| 'pub/pancake.js': ['src/js/milk.js', 'src/js/flour.js', 'src/js/eggs.js'] | |
| } | |
| } | |
| }, | |
| sass: { | |
| css: { | |
| options: { | |
| sourcemap: 'none', | |
| style: 'compressed', | |
| noCache: true, | |
| update: true | |
| }, | |
| files: { | |
| // These are all of the css files we want compiled. | |
| // Note that imports within the files are handled properly | |
| // and we don't need to include them here. | |
| 'pub/blueberry.css': 'src/css/blueberry.scss', | |
| 'pub/yogurt.css': 'src/css/yogurt.scss' | |
| } | |
| } | |
| }, | |
| // `grunt copy` syncs i/ and lib/. | |
| copy: { | |
| all: { | |
| cwd: 'src', | |
| // These are the directories to be copied as-is. | |
| // These must also be specified below in the watch block. | |
| src: ['i/**', 'lib/**'], | |
| dest: 'pub', | |
| expand: true | |
| }, | |
| }, | |
| // `grunt clean` is equivalent to `rm -rf pub`. | |
| clean: ['pub'], | |
| // `grunt watch` monitors the source directories and updates pub/ as needed. | |
| watch: { | |
| js: { | |
| files: ['src/js/**'], | |
| tasks: ['uglify'] | |
| }, | |
| css: { | |
| files: ['src/css/**'], | |
| tasks: ['sass'] | |
| }, | |
| copy: { | |
| files: ['src/i/**', 'src/lib/**'], | |
| tasks: ['copy'] | |
| } | |
| } | |
| }); | |
| // These should match what's in package.json. | |
| grunt.loadNpmTasks('grunt-contrib-uglify'); | |
| grunt.loadNpmTasks('grunt-contrib-sass'); | |
| grunt.loadNpmTasks('grunt-contrib-copy'); | |
| grunt.loadNpmTasks('grunt-contrib-clean'); | |
| grunt.loadNpmTasks('grunt-contrib-watch'); | |
| // `grunt build` updates all of the js and css. | |
| grunt.registerTask('build', ['uglify', 'sass']); | |
| // `grunt all` does a complete rebuild and is the default action. | |
| grunt.registerTask('all', ['clean', 'build', 'copy']); | |
| grunt.registerTask('default', ['all']); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment