text: module.exports = function (grunt) {
  
      /**
       * Load required Grunt tasks. These are installed based on the versions listed
       * in `package.json` when you do `npm install` in this directory.
       */
      grunt.loadNpmTasks('grunt-contrib-clean');
      grunt.loadNpmTasks('grunt-contrib-copy');
      grunt.loadNpmTasks('grunt-contrib-jshint');
      grunt.loadNpmTasks('grunt-contrib-watch');
      grunt.loadNpmTasks('grunt-ngmin');
      grunt.loadNpmTasks('grunt-bower-install');
  
      /**
       * Load in our build configuration file.
       */
      var userConfig = require('./build.config.js');
  
      /**
       * This is the configuration object Grunt uses to give each plugin its
       * instructions.
       */
      var taskConfig = {
          /**
           * We read in our `package.json` file so we can access the package name and
           * version. It's already there, so we don't repeat ourselves here.
           */
          pkg: grunt.file.readJSON("package.json"),
  
          /**
           * The directories to delete when `grunt clean` is executed.
           */
          clean: [
              '<%= build_dir %>'
          ],
  
          /**
           * The `copy` task just copies files from A to B. We use it here to copy
           * our project assets (images, fonts, etc.) and javascripts into
           * `build_dir`, and then to copy the assets to `compile_dir`.
           */
          copy: {
              build_app_assets: {
                  files: [
                      {
                          src: [ '**' ],
                          dest: '<%= build_dir %>/assets/',
                          cwd: 'src/assets',
                          expand: true
                      }
                  ]
              },
              build_app_tpl: {
                  files: [
                      {
                          src: [ '<%= app_files.tpl %>' ],
                          dest: '<%= build_dir %>/pages/',
                          cwd: '.',
                          expand: true,
                          flatten: true
                      }
                  ]
              },
              build_app_css: {
                  files: [
                      {
                          src: [ '<%= app_files.css %>' ],
                          dest: '<%= build_dir %>/css/',
                          cwd: '.',
                          expand: true,
                          flatten: true
                      }
                  ]
              },
              build_bower_assets: {
                  files: [
                      {
                          src: [ '<%= bower_files.assets %>' ],
                          dest: '<%= build_dir %>/assets/',
                          cwd: '.',
                          expand: true,
                          flatten: true
                      }
                  ]
              },
              build_appjs: {
                  files: [
                      {
                          src: [ '<%= app_files.js %>' ],
                          dest: '<%= build_dir %>/js',
                          cwd: '.',
                          expand: true,
                          flatten: true
                      }
                  ]
              },
              build_bowerjs: {
                  files: [
                      {
                          src: [ '<%= bower_files.js %>','<%= bower_files.css %>' ],
                          dest: '<%= build_dir %>/',
                          cwd: '.',
                          expand: true
                      }
                  ]
              }
          },
  
          /**
           * `ng-min` annotates the sources before minifying. That is, it allows us
           * to code without the array syntax.
           */
          ngmin: {
              compile: {
                  files: [
                      {
                          src: [ '<%= app_files.js %>' ],
                          cwd: '<%= build_dir %>',
                          dest: '<%= build_dir %>',
                          expand: true
                      }
                  ]
              }
          },
  
          bowerInstall: {
              target: {
                  src: [
                      'build/index.html'
                  ]
              }
          },
  
          /**
           * `jshint` defines the rules of our linter as well as which files we
           * should check. This file, all javascript sources, and all our unit tests
           * are linted based on the policies listed in `options`. But we can also
           * specify exclusionary patterns by prefixing them with an exclamation
           * point (!); this is useful when code comes from a third party but is
           * nonetheless inside `src/`.
           */
          jshint: {
              src: [
                  '<%= app_files.js %>'
              ],
              options: {
                  bitwise: true,
                  curly: true,
                  eqeqeq: true,
                  eqnull: true,
                  evil: true,
                  forin: true,
                  globalstrict: true,
                  immed: true,
                  latedef: false,
                  newcap: true,
                  noarg: true,
                  noempty: true,
                  nonew: true,
                  trailing: true,
                  undef: true,
                  unused: true,
  
                  camelcase: true,
                  indent: 4,
                  quotmark: 'single',
  
                  '-W055': true,
                  '-W098': true,
                  '-W116': true,
  
                  globals: {
                      angular: false,
                      module: false,
                      $: false,
                      window: false,
                      console: false,
                      confirm: false
                  }
              }
          },
  
          /**
           * The `index` task compiles the `index.html` file as a Grunt template. CSS
           * and JS files co-exist here but they get split apart later.
           */
          index: {
  
              /**
               * During development, we don't want to have wait for compilation,
               * concatenation, minification, etc. So to avoid these steps, we simply
               * add all script files directly to the `<head>` of `index.html`. The
               * `src` property contains the list of included files.
               */
              build: {
                  dir: '<%= build_dir %>',
                  src: [
                      '<%= bower_files.js %>',
                      '<%= build_dir %>/js/**/*.js',
                      '<%= bower_files.css %>',
                      '<%= build_dir %>/css/**/*.css',
                  ]
              }
          },
  
          /**
           * And for rapid development, we have a watch set up that checks to see if
           * any of the files listed below change, and then to execute the listed
           * tasks when they do. This just saves us from having to type "grunt" into
           * the command-line every time we want to see what we're working on; we can
           * instead just leave "grunt watch" running in a background terminal. Set it
           * and forget it, as Ron Popeil used to tell us.
           *
           * But we don't need the same thing to happen for all the files.
           */
          delta: {
              /**
               * By default, we want the Live Reload to work for all tasks; this is
               * overridden in some tasks (like this file) where browser resources are
               * unaffected. It runs by default on port 35729, which your browser
               * plugin should auto-detect.
               */
              options: {
                  livereload: true
              },
  
              /**
               * When the Gruntfile changes, we just want to lint it. In fact, when
               * your Gruntfile changes, it will automatically be reloaded!
               */
              gruntfile: {
                  files: 'Gruntfile.js',
                  tasks: [ 'jshint:gruntfile' ],
                  options: {
                      livereload: false
                  }
              },
  
              /**
               * When our JavaScript source files change, we want to run lint them and
               * run our unit tests.
               */
              jssrc: {
                  files: [
                      '<%= app_files.js %>'
                  ],
                  tasks: [ 'jshint:src', 'copy:build_appjs' ]
              },
  
              /**
               * When assets are changed, copy them. Note that this will *not* copy new
               * files, so this is probably not very useful.
               */
              assets: {
                  files: [
                      'src/assets/**/*'
                  ],
                  tasks: [ 'copy:build_app_assets', 'copy:build_bower_assets' ]
              },
  
              /**
               * When index.html changes, we need to compile it.
               */
              html: {
                  files: [ '<%= app_files.html %>' ],
                  tasks: [ 'index:build' ]
              }
          }
      };
  
      grunt.initConfig(grunt.util._.extend(taskConfig, userConfig));
  
      /**
       * In order to make it safe to just compile or copy *only* what was changed,
       * we need to ensure we are starting from a clean, fresh build. So we rename
       * the `watch` task to `delta` (that's why the configuration var above is
       * `delta`) and then add a new task called `watch` that does a clean build
       * before watching for changes.
       */
      grunt.renameTask('watch', 'delta');
      grunt.registerTask('watch', [ 'build', 'delta' ]);
  
      /**
       * The default task is to build and compile.
       */
      grunt.registerTask('default', [ 'build']);
  
      /**
       * The `build` task gets your app ready to run for development and testing.
       */
      grunt.registerTask('build', [
          'clean', 'jshint',
          'copy:build_app_assets', 'copy:build_bower_assets', 'copy:build_app_tpl', 'copy:build_app_css',
          'copy:build_appjs', 'ngmin', 'copy:build_bowerjs', 'index:build', 'bowerInstall'
      ]);
  
      /**
       * A utility function to get all app JavaScript sources.
       */
      function filterForJS(files) {
          return files.filter(function (file) {
              return file.match(/\.js$/);
          });
      }
  
      /**
       * A utility function to get all app CSS sources.
       */
      function filterForCSS(files) {
          return files.filter(function (file) {
              return file.match(/\.css$/);
          });
      }
  
      /**
       * The index.html template includes the stylesheet and javascript sources
       * based on dynamic names calculated in this Gruntfile. This task assembles
       * the list into variables for the template to use and then runs the
       * compilation.
       */
      grunt.registerMultiTask('index', 'Process index.html template', function () {
          var dirRE = new RegExp('^(' + grunt.config('build_dir') + '|' + grunt.config('compile_dir') + ')\/', 'g');
          var jsFiles = filterForJS(this.filesSrc).map(function (file) {
              return file.replace(dirRE, '');
          });
          var cssFiles = filterForCSS(this.filesSrc).map(function (file) {
              return file.replace(dirRE, '');
          });
  
          grunt.file.copy('src/index.html', this.data.dir + '/index.html', {
              process: function (contents, path) {
                  return grunt.template.process(contents, {
                      data: {
                          scripts: jsFiles,
                          styles: cssFiles,
                          version: grunt.config('pkg.version')
                      }
                  });
              }
          });
      });
  };
  