Created
January 29, 2013 20:21
-
-
Save fmal/4667396 to your computer and use it in GitHub Desktop.
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) { | |
| 'use strict'; | |
| grunt.initConfig({ | |
| staging: 'dist/debug/', | |
| production: 'dist/release/', | |
| pkg: grunt.file.readJSON('package.json'), | |
| // The clean task ensures all files are removed from the dist/ directory so | |
| // that no files linger from previous builds. | |
| clean: ['dist/', 'app/components/'], | |
| // Install Bower components using only the specified main file, instead of | |
| // the whole repository. | |
| bower: { | |
| install: { | |
| options: { | |
| targetDir: 'app/components' | |
| } | |
| } | |
| }, | |
| // The lint task will run the build configuration and the application | |
| // JavaScript through JSHint and report any errors. | |
| jshint: { | |
| all: ['Gruntfile.js', 'app/scripts/**/*.js'], | |
| options: { | |
| jshintrc: './.jshintrc', | |
| } | |
| }, | |
| // Precompile templates with Handlebars | |
| handlebars: { | |
| dist: { | |
| options: { | |
| namespace: 'JST' | |
| }, | |
| files: { | |
| '<%= staging %>scripts/templates.js': 'app/templates/**/*.hb', | |
| } | |
| } | |
| }, | |
| requirejs: { | |
| dist: { | |
| options: { | |
| baseUrl: 'app/scripts', | |
| mainConfigFile: 'app/scripts/config.js', | |
| name: 'config', | |
| // Output file. | |
| out: '<%= staging %>scripts/require.js', | |
| // TODO: Build Handlebars runtime, instead of full version. | |
| // paths: { | |
| // handlebars: '../assets/js/libs/handlebars.runtime-1.0.0.beta' | |
| // } | |
| } | |
| } | |
| }, | |
| // The concatenate task is used here to merge the almond require/define | |
| // shim and the templates into the application code. It's named | |
| // <%= staging %>require.js, because we want to only load one script file in | |
| // index.html. | |
| concat: { | |
| dist: { | |
| src: [ | |
| '<%= staging %>scripts/templates.js', | |
| '<%= staging %>scripts/require.js' | |
| ], | |
| dest: '<%= staging %>scripts/require.js', | |
| separator: ';' | |
| } | |
| }, | |
| compass: { | |
| options: { | |
| sassDir: 'app/styles', | |
| cssDir: '<%= staging %>styles', | |
| }, | |
| dist: {}, | |
| release: { | |
| options: { | |
| debugInfo: true | |
| } | |
| } | |
| }, | |
| // TODO: Implement reload | |
| // reload: { | |
| // // The port reload is served from | |
| // port: 3001, | |
| // proxy: { | |
| // host: 'localhost', | |
| // port: 3000 | |
| // } | |
| // }, | |
| watch: { | |
| // When a CSS change is detected, recompile with Compass and run the reload task | |
| compass: { | |
| files: ['app/styles/**/*.{scss,sass}'], | |
| tasks: ['compass', 'reload'] | |
| }, | |
| // When a change is detected in other file, run the reload task | |
| reload: { | |
| files: [ | |
| 'app/*.html', | |
| 'app/styles/**/*.css', | |
| 'app/scripts/**/*.js', | |
| 'app/images/**/*' | |
| ], | |
| tasks: 'reload' | |
| } | |
| }, | |
| // Takes the built require.js file and minifies it for filesize benefits. | |
| uglify: { | |
| dist: { | |
| files: { | |
| '<%= production %>scripts/require.js': ['<%= staging %>scripts/require.js'] | |
| } | |
| } | |
| }, | |
| // This task uses the MinCSS Node.js project to take all your CSS files in | |
| // order and concatenate them into a single CSS file named index.css. It | |
| // also minifies all the CSS as well. This is named index.css, because we | |
| // only want to load one stylesheet in index.html. | |
| mincss: { | |
| dist: { | |
| files: { | |
| '<%= production %>styles/main.css': ['<%= staging %>styles/main.css'] | |
| } | |
| } | |
| } | |
| }) | |
| grunt.loadNpmTasks('grunt-contrib-watch') | |
| grunt.loadNpmTasks('grunt-contrib-compass') | |
| grunt.loadNpmTasks('grunt-contrib-jshint') | |
| grunt.loadNpmTasks('grunt-contrib-requirejs') | |
| grunt.loadNpmTasks('grunt-contrib-clean') | |
| grunt.loadNpmTasks('grunt-contrib-handlebars') | |
| grunt.loadNpmTasks('grunt-contrib-concat') | |
| grunt.loadNpmTasks('grunt-contrib-uglify') | |
| grunt.loadNpmTasks('grunt-reload') | |
| grunt.loadNpmTasks('grunt-contrib-mincss') | |
| grunt.loadNpmTasks('grunt-bower-task') | |
| // The debug task will remove all contents inside the dist/ folder, lint | |
| // all your code, precompile all the underscore templates into | |
| // <%= staging %>scripts/templates.js, compile all the application code into | |
| // <%= staging %>scripts/require.js, and then concatenate the | |
| // <%= staging %>scripts/templates.js into the require.js file. | |
| grunt.registerTask('debug', ['clean', 'bower', 'jshint', 'handlebars', 'requirejs', 'concat', 'compass:dist']) | |
| // The release task will run the debug tasks and then minify the | |
| // <%= staging %>scripts/require.js file and CSS files. | |
| grunt.registerTask('release', ['clean', 'bower', 'jshint', 'handlebars', 'requirejs', 'concat', 'compass:release', 'uglify', 'mincss']) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment