|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +module.exports = function (grunt) { |
| 4 | + |
| 5 | + // Load grunt tasks automatically |
| 6 | + require('load-grunt-tasks')(grunt); |
| 7 | + |
| 8 | + // Time how long tasks take. Can help when optimizing build times |
| 9 | + require('time-grunt')(grunt); |
| 10 | + |
| 11 | + // Configurable paths for the application |
| 12 | + var appConfig = { |
| 13 | + app: require('./bower.json').appPath || 'app', |
| 14 | + src: 'src', |
| 15 | + dist: 'dist' |
| 16 | + }; |
| 17 | + |
| 18 | + // Define the configuration for all the tasks |
| 19 | + grunt.initConfig({ |
| 20 | + |
| 21 | + // Project settings |
| 22 | + yeoman: appConfig, |
| 23 | + |
| 24 | + // Watches files for changes and runs tasks based on the changed files |
| 25 | + watch: { |
| 26 | + bower: { |
| 27 | + files: ['bower.json'], |
| 28 | + tasks: ['wiredep'] |
| 29 | + }, |
| 30 | + js: { |
| 31 | + files: ['<%= yeoman.src %>/*.js'], |
| 32 | + tasks: ['concat:src'] |
| 33 | + }, |
| 34 | + dist: { |
| 35 | + files: ['<%= yeoman.app %>/js/formus.js'], |
| 36 | + tasks: ['concat:dist'] |
| 37 | + } |
| 38 | + }, |
| 39 | + |
| 40 | + // Make sure code styles are up to par and there are no obvious mistakes |
| 41 | + jshint: { |
| 42 | + options: { |
| 43 | + jshintrc: '.jshintrc', |
| 44 | + reporter: require('jshint-stylish') |
| 45 | + }, |
| 46 | + src: { |
| 47 | + src: [ |
| 48 | + 'Gruntfile.js', |
| 49 | + '<%= yeoman.src %>/*.js' |
| 50 | + ] |
| 51 | + } |
| 52 | + }, |
| 53 | + |
| 54 | + // Empties folders to start fresh |
| 55 | + clean: { |
| 56 | + dist: { |
| 57 | + files: [ |
| 58 | + { |
| 59 | + dot: true, |
| 60 | + src: [ |
| 61 | + '.tmp', |
| 62 | + '<%= yeoman.dist %>/{,*/}*', |
| 63 | + '!<%= yeoman.dist %>/.git*' |
| 64 | + ] |
| 65 | + } |
| 66 | + ] |
| 67 | + }, |
| 68 | + server: '.tmp' |
| 69 | + }, |
| 70 | + |
| 71 | + // Automatically inject Bower components into the app |
| 72 | + wiredep: { |
| 73 | + app: { |
| 74 | + src: ['<%= yeoman.app %>/index.html'], |
| 75 | + dependencies: true, |
| 76 | + devDependencies: true |
| 77 | + } |
| 78 | + }, |
| 79 | + concat: { |
| 80 | + options: { |
| 81 | + separator: ';' |
| 82 | + }, |
| 83 | + src: { |
| 84 | + src: '<%= yeoman.src %>/*.js', |
| 85 | + dest: '<%= yeoman.app %>/js/formus.js' |
| 86 | + }, |
| 87 | + dist: { |
| 88 | + src: '<%= yeoman.src %>/*.js', |
| 89 | + dest: '<%= yeoman.dist %>/formus.js' |
| 90 | + } |
| 91 | + }, |
| 92 | + |
| 93 | + |
| 94 | + // Copies remaining files to places other tasks can use |
| 95 | + copy: { |
| 96 | + dist: { |
| 97 | + files: [ |
| 98 | + ] |
| 99 | + }, |
| 100 | + styles: { |
| 101 | + expand: true, |
| 102 | + cwd: '<%= yeoman.app %>/styles', |
| 103 | + dest: '.tmp/styles/', |
| 104 | + src: '{,*/}*.css' |
| 105 | + } |
| 106 | + }, |
| 107 | + ngtemplates: { |
| 108 | + app: { |
| 109 | + cwd: '<%= yeoman.app %>', |
| 110 | + src: ['views/**/*.html','views/*.html'], |
| 111 | + dest: '<%= yeoman.app %>/scripts/templates.js', |
| 112 | + options: { |
| 113 | + htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + }); |
| 118 | + |
| 119 | + grunt.registerTask('default', [ |
| 120 | + 'watch' |
| 121 | + ]); |
| 122 | +}; |
0 commit comments