Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Generated on 2014-10-25 using generator-angular 0.9.8
  2. 'use strict';
  3.  
  4. // # Globbing
  5. // for performance reasons we're only matching one level down:
  6. // 'test/spec/{,*/}*.js'
  7. // use this if you want to recursively match all subfolders:
  8. // 'test/spec/**/*.js'
  9.  
  10. module.exports = function (grunt) {
  11.  
  12.   // Load grunt tasks automatically
  13.   require('load-grunt-tasks')(grunt);
  14.  
  15.   // Time how long tasks take. Can help when optimizing build times
  16.   require('time-grunt')(grunt);
  17.  
  18.   // Configurable paths for the application
  19.   var appConfig = {
  20.     app: require('./bower.json').appPath || 'app',
  21.     dist: 'dist'
  22.   };
  23.  
  24.   // Define the configuration for all the tasks
  25.   grunt.initConfig({
  26.  
  27.     // Project settings
  28.     yeoman: appConfig,
  29.  
  30.     // Watches files for changes and runs tasks based on the changed files
  31.     watch: {
  32.       bower: {
  33.         files: ['bower.json'],
  34.         tasks: ['wiredep']
  35.       },
  36.       js: {
  37.         files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
  38.         tasks: ['newer:jshint:all'],
  39.         options: {
  40.           livereload: '<%= connect.options.livereload %>'
  41.         }
  42.       },
  43.       gruntfile: {
  44.         files: ['Gruntfile.js']
  45.       },
  46.       livereload: {
  47.         options: {
  48.           livereload: '<%= connect.options.livereload %>'
  49.         },
  50.         files: [
  51.           '<%= yeoman.app %>/{,*/}*.html',
  52.           '.tmp/styles/{,*/}*.css',
  53.           '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  54.         ]
  55.       }
  56.     },
  57.  
  58.     // The actual grunt server settings
  59.     connect: {
  60.       options: {
  61.         port: 9000,
  62.         // Change this to '0.0.0.0' to access the server from outside.
  63.         hostname: '0.0.0.0',
  64.         livereload: 35729
  65.       },
  66.       livereload: {
  67.         options: {
  68.           open: true,
  69.           middleware: function (connect) {
  70.             return [
  71.               connect.static('.tmp'),
  72.               connect().use(
  73.                 '/bower_components',
  74.                 connect.static('./bower_components')
  75.               ),
  76.               connect.static(appConfig.app)
  77.             ];
  78.           }
  79.         }
  80.       },
  81.       dist: {
  82.         options: {
  83.           open: true,
  84.           base: '<%= yeoman.dist %>'
  85.         }
  86.       }
  87.     },
  88.  
  89.     // Make sure code styles are up to par and there are no obvious mistakes
  90.     jshint: {
  91.       options: {
  92.         jshintrc: '.jshintrc',
  93.         reporter: require('jshint-stylish')
  94.       },
  95.       all: {
  96.         src: [
  97.           'Gruntfile.js',
  98.           '<%= yeoman.app %>/scripts/{,*/}*.js'
  99.         ]
  100.       },
  101.       test: {
  102.         options: {
  103.           jshintrc: 'test/.jshintrc'
  104.         },
  105.         src: ['test/spec/{,*/}*.js']
  106.       }
  107.     },
  108.  
  109.     // Empties folders to start fresh
  110.     clean: {
  111.       dist: {
  112.         files: [{
  113.           dot: true,
  114.           src: [
  115.             '.tmp',
  116.             '<%= yeoman.dist %>/{,*/}*',
  117.             '!<%= yeoman.dist %>/.git*'
  118.           ]
  119.         }]
  120.       },
  121.       server: '.tmp'
  122.     },
  123.  
  124.  
  125.     // Automatically inject Bower components into the app
  126.     wiredep: {
  127.       app: {
  128.         src: ['<%= yeoman.app %>/index.html'],
  129.         ignorePath:  /\.\.\//
  130.       }
  131.     },
  132.  
  133.     // Renames files for browser caching purposes
  134.     filerev: {
  135.       dist: {
  136.         src: [
  137.           '<%= yeoman.dist %>/scripts/{,*/}*.js',
  138.           '<%= yeoman.dist %>/styles/{,*/}*.css',
  139.           '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  140.           '<%= yeoman.dist %>/styles/fonts/*'
  141.         ]
  142.       }
  143.     },
  144.  
  145.     // Reads HTML for usemin blocks to enable smart builds that automatically
  146.     // concat, minify and revision files. Creates configurations in memory so
  147.     // additional tasks can operate on them
  148.     useminPrepare: {
  149.       html: '<%= yeoman.app %>/index.html',
  150.       options: {
  151.         dest: '<%= yeoman.dist %>',
  152.         flow: {
  153.           html: {
  154.             steps: {
  155.               js: ['concat', 'uglifyjs'],
  156.               css: ['cssmin']
  157.             },
  158.             post: {}
  159.           }
  160.         }
  161.       }
  162.     },
  163.  
  164.     // Performs rewrites based on filerev and the useminPrepare configuration
  165.     usemin: {
  166.       html: ['<%= yeoman.dist %>/{,*/}*.html'],
  167.       css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  168.       options: {
  169.         assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
  170.       }
  171.     },
  172.  
  173.     // The following *-min tasks will produce minified files in the dist folder
  174.     // By default, your `index.html`'s <!-- Usemin block --> will take care of
  175.     // minification. These next options are pre-configured if you do not wish
  176.     // to use the Usemin blocks.
  177.     // cssmin: {
  178.     //   dist: {
  179.     //     files: {
  180.     //       '<%= yeoman.dist %>/styles/main.css': [
  181.     //         '.tmp/styles/{,*/}*.css'
  182.     //       ]
  183.     //     }
  184.     //   }
  185.     // },
  186.     // uglify: {
  187.     //   dist: {
  188.     //     files: {
  189.     //       '<%= yeoman.dist %>/scripts/scripts.js': [
  190.     //         '<%= yeoman.dist %>/scripts/scripts.js'
  191.     //       ]
  192.     //     }
  193.     //   }
  194.     // },
  195.     // concat: {
  196.     //   dist: {}
  197.     // },
  198.  
  199.     //imagemin: {
  200.     //  dist: {
  201.     //    files: [{
  202.     //      expand: true,
  203.     //      cwd: '<%= yeoman.app %>/images',
  204.     //      src: '{,*/}*.{png,jpg,jpeg,gif}',
  205.     //      dest: '<%= yeoman.dist %>/images'
  206.     //    }]
  207.     //  }
  208.     //},
  209.    
  210.  
  211.     htmlmin: {
  212.       dist: {
  213.         options: {
  214.           collapseWhitespace: true,
  215.           conservativeCollapse: true,
  216.           collapseBooleanAttributes: true,
  217.           removeCommentsFromCDATA: true,
  218.           removeOptionalTags: true
  219.         },
  220.         files: [{
  221.           expand: true,
  222.           cwd: '<%= yeoman.dist %>',
  223.           src: ['*.html', 'views/{,*/}*.html'],
  224.           dest: '<%= yeoman.dist %>'
  225.         }]
  226.       }
  227.     },
  228.  
  229.     // ng-annotate tries to make the code safe for minification automatically
  230.     // by using the Angular long form for dependency injection.
  231.     ngAnnotate: {
  232.       dist: {
  233.         files: [{
  234.           expand: true,
  235.           cwd: '.tmp/concat/scripts',
  236.           src: ['*.js', '!oldieshim.js'],
  237.           dest: '.tmp/concat/scripts'
  238.         }]
  239.       }
  240.     },
  241.  
  242.     // Replace Google CDN references
  243.     cdnify: {
  244.       dist: {
  245.         html: ['<%= yeoman.dist %>/*.html']
  246.       }
  247.     },
  248.  
  249.     // Copies remaining files to places other tasks can use
  250.     copy: {
  251.       dist: {
  252.         files: [{
  253.           expand: true,
  254.           dot: true,
  255.           cwd: '<%= yeoman.app %>',
  256.           dest: '<%= yeoman.dist %>',
  257.           src: [
  258.             '*.{ico,png,txt}',
  259.             '.htaccess',
  260.             '*.html',
  261.             'views/{,*/}*.html',
  262.             'images/{,*/}*.{webp}',
  263.             'fonts/*'
  264.           ]
  265.         }, {
  266.           expand: true,
  267.           cwd: '.tmp/images',
  268.           dest: '<%= yeoman.dist %>/images',
  269.           src: ['generated/*']
  270.         }, {
  271.           expand: true,
  272.           cwd: 'bower_components/bootstrap/dist',
  273.           src: 'fonts/*',
  274.           dest: '<%= yeoman.dist %>'
  275.         }]
  276.       },
  277.       styles: {
  278.         expand: true,
  279.         cwd: '<%= yeoman.app %>/styles',
  280.         dest: '.tmp/styles/',
  281.         src: '{,*/}*.css'
  282.       }
  283.     },
  284.  
  285.     // Run some tasks in parallel to speed up the build process
  286.     concurrent: {
  287.       server: [
  288.         'copy:styles'
  289.       ],
  290.       test: [
  291.         'copy:styles'
  292.       ],
  293.       dist: [
  294.         'copy:styles',
  295.       ]
  296.     }
  297.  
  298.   });
  299.  
  300.  
  301.   grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  302.     if (target === 'dist') {
  303.       return grunt.task.run(['build', 'connect:dist:keepalive']);
  304.     }
  305.  
  306.     grunt.task.run([
  307.       'clean:server',
  308.       'wiredep',
  309.       'concurrent:server',
  310.       'connect:livereload',
  311.       'watch'
  312.     ]);
  313.   });
  314.  
  315.   grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
  316.     grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  317.     grunt.task.run(['serve:' + target]);
  318.   });
  319.  
  320.   grunt.registerTask('build', [
  321.     'clean:dist',
  322.     'wiredep',
  323.     'useminPrepare',
  324.     'concurrent:dist',
  325.     //'concat',
  326.     //'ngAnnotate',
  327.     'copy:dist',
  328.     'cdnify',
  329.     //'cssmin',
  330.     //'uglify',
  331.     'filerev',
  332.     'usemin',
  333.     'htmlmin'
  334.   ]);
  335.  
  336.   grunt.registerTask('default', [
  337.     'newer:jshint',
  338.     'build'
  339.   ]);
  340. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement