Guest User

Untitled

a guest
Nov 16th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Generated on 2014-11-13 using generator-angular 0.10.0
  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 || 'src',
  21.     dist: 'build'
  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.       jsTest: {
  44.         files: ['test/spec/{,*/}*.js'],
  45.         tasks: ['newer:jshint:test', 'karma']
  46.       },
  47.       styles: {
  48.         files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
  49.         tasks: ['newer:copy:styles', 'autoprefixer']
  50.       },
  51.       gruntfile: {
  52.         files: ['Gruntfile.js']
  53.       },
  54.       livereload: {
  55.         options: {
  56.           livereload: '<%= connect.options.livereload %>'
  57.         },
  58.         files: [
  59.           '<%= yeoman.app %>/{,*/}*.html',
  60.           '.tmp/styles/{,*/}*.css',
  61.           '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  62.         ]
  63.       }
  64.     },
  65.  
  66.     // The actual grunt server settings
  67.     connect: {
  68.       options: {
  69.         port: 9000,
  70.         // Change this to '0.0.0.0' to access the server from outside.
  71.         hostname: 'localhost',
  72.         livereload: 35729
  73.       },
  74.       livereload: {
  75.         options: {
  76.           open: true,
  77.           middleware: function (connect) {
  78.             return [
  79.               connect.static('.tmp'),
  80.               connect().use(
  81.                 '/bower_components',
  82.                 connect.static('./bower_components')
  83.               ),
  84.               connect.static(appConfig.app)
  85.             ];
  86.           }
  87.         }
  88.       },
  89.       test: {
  90.         options: {
  91.           port: 9001,
  92.           middleware: function (connect) {
  93.             return [
  94.               connect.static('.tmp'),
  95.               connect.static('test'),
  96.               connect().use(
  97.                 '/bower_components',
  98.                 connect.static('./bower_components')
  99.               ),
  100.               connect.static(appConfig.app)
  101.             ];
  102.           }
  103.         }
  104.       },
  105.       dist: {
  106.         options: {
  107.           open: true,
  108.           base: '<%= yeoman.dist %>'
  109.         }
  110.       }
  111.     },
  112.  
  113.     // Make sure code styles are up to par and there are no obvious mistakes
  114.     jshint: {
  115.       options: {
  116.         jshintrc: '.jshintrc',
  117.         reporter: require('jshint-stylish')
  118.       },
  119.       all: {
  120.         src: [
  121.           'Gruntfile.js',
  122.           '<%= yeoman.app %>/scripts/{,*/}*.js'
  123.         ]
  124.       },
  125.       test: {
  126.         options: {
  127.           jshintrc: 'test/.jshintrc'
  128.         },
  129.         src: ['test/spec/{,*/}*.js']
  130.       }
  131.     },
  132.  
  133.     // Empties folders to start fresh
  134.     clean: {
  135.       dist: {
  136.         files: [{
  137.           dot: true,
  138.           src: [
  139.             '.tmp',
  140.             '<%= yeoman.dist %>/{,*/}*',
  141.             '!<%= yeoman.dist %>/.git{,*/}*'
  142.           ]
  143.         }]
  144.       },
  145.       server: '.tmp'
  146.     },
  147.  
  148.     // Add vendor prefixed styles
  149.     autoprefixer: {
  150.       options: {
  151.         browsers: ['last 1 version']
  152.       },
  153.       dist: {
  154.         files: [{
  155.           expand: true,
  156.           cwd: '.tmp/styles/',
  157.           src: '{,*/}*.css',
  158.           dest: '.tmp/styles/'
  159.         }]
  160.       }
  161.     },
  162.  
  163.     // Automatically inject Bower components into the app
  164.     wiredep: {
  165.       app: {
  166.         src: ['<%= yeoman.app %>/index.html'],
  167.         ignorePath:  /\.\.\//
  168.       }
  169.     },
  170.  
  171.     // Renames files for browser caching purposes
  172.     filerev: {
  173.       dist: {
  174.         src: [
  175.           '<%= yeoman.dist %>/scripts/{,*/}*.js',
  176.           '<%= yeoman.dist %>/styles/{,*/}*.css',
  177.           '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  178.           '<%= yeoman.dist %>/styles/fonts/*'
  179.         ]
  180.       }
  181.     },
  182.  
  183.     // Reads HTML for usemin blocks to enable smart builds that automatically
  184.     // concat, minify and revision files. Creates configurations in memory so
  185.     // additional tasks can operate on them
  186.     useminPrepare: {
  187.       html: '<%= yeoman.app %>/index.html',
  188.       options: {
  189.         dest: '<%= yeoman.dist %>',
  190.         flow: {
  191.           html: {
  192.             steps: {
  193.               js: ['concat', 'uglifyjs'],
  194.               css: ['cssmin']
  195.             },
  196.             post: {}
  197.           }
  198.         }
  199.       }
  200.     },
  201.  
  202.     // Performs rewrites based on filerev and the useminPrepare configuration
  203.     usemin: {
  204.       html: ['<%= yeoman.dist %>/{,*/}*.html'],
  205.       css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  206.       options: {
  207.         assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
  208.       }
  209.     },
  210.  
  211.     // The following *-min tasks will produce minified files in the dist folder
  212.     // By default, your `index.html`'s <!-- Usemin block --> will take care of
  213.     // minification. These next options are pre-configured if you do not wish
  214.     // to use the Usemin blocks.
  215.     // cssmin: {
  216.     //   dist: {
  217.     //     files: {
  218.     //       '<%= yeoman.dist %>/styles/main.css': [
  219.     //         '.tmp/styles/{,*/}*.css'
  220.     //       ]
  221.     //     }
  222.     //   }
  223.     // },
  224.     // uglify: {
  225.     //   dist: {
  226.     //     files: {
  227.     //       '<%= yeoman.dist %>/scripts/scripts.js': [
  228.     //         '<%= yeoman.dist %>/scripts/scripts.js'
  229.     //       ]
  230.     //     }
  231.     //   }
  232.     // },
  233.     // concat: {
  234.     //   dist: {}
  235.     // },
  236.  
  237.     imagemin: {
  238.       dist: {
  239.         files: [{
  240.           expand: true,
  241.           cwd: '<%= yeoman.app %>/images',
  242.           src: '{,*/}*.{png,jpg,jpeg,gif}',
  243.           dest: '<%= yeoman.dist %>/images'
  244.         }]
  245.       }
  246.     },
  247.  
  248.     svgmin: {
  249.       dist: {
  250.         files: [{
  251.           expand: true,
  252.           cwd: '<%= yeoman.app %>/images',
  253.           src: '{,*/}*.svg',
  254.           dest: '<%= yeoman.dist %>/images'
  255.         }]
  256.       }
  257.     },
  258.  
  259.     htmlmin: {
  260.       dist: {
  261.         options: {
  262.           collapseWhitespace: true,
  263.           conservativeCollapse: true,
  264.           collapseBooleanAttributes: true,
  265.           removeCommentsFromCDATA: true,
  266.           removeOptionalTags: true
  267.         },
  268.         files: [{
  269.           expand: true,
  270.           cwd: '<%= yeoman.dist %>',
  271.           src: ['*.html', 'views/{,*/}*.html'],
  272.           dest: '<%= yeoman.dist %>'
  273.         }]
  274.       }
  275.     },
  276.  
  277.     // ng-annotate tries to make the code safe for minification automatically
  278.     // by using the Angular long form for dependency injection.
  279.     ngAnnotate: {
  280.       dist: {
  281.         files: [{
  282.           expand: true,
  283.           cwd: '.tmp/concat/scripts',
  284.           src: ['*.js', '!oldieshim.js'],
  285.           dest: '.tmp/concat/scripts'
  286.         }]
  287.       }
  288.     },
  289.  
  290.     // Replace Google CDN references
  291.     cdnify: {
  292.       dist: {
  293.         html: ['<%= yeoman.dist %>/*.html']
  294.       }
  295.     },
  296.  
  297.     // Copies remaining files to places other tasks can use
  298.     copy: {
  299.       dist: {
  300.         files: [{
  301.           expand: true,
  302.           dot: true,
  303.           cwd: '<%= yeoman.app %>',
  304.           dest: '<%= yeoman.dist %>',
  305.           src: [
  306.             '*.{ico,png,txt}',
  307.             '.htaccess',
  308.             '*.html',
  309.             'views/{,*/}*.html',
  310.             'images/{,*/}*.{webp}',
  311.             'fonts/{,*/}*.*'
  312.           ]
  313.         }, {
  314.           expand: true,
  315.           cwd: '.tmp/images',
  316.           dest: '<%= yeoman.dist %>/images',
  317.           src: ['generated/*']
  318.         }]
  319.       },
  320.       styles: {
  321.         expand: true,
  322.         cwd: '<%= yeoman.app %>/styles',
  323.         dest: '.tmp/styles/',
  324.         src: '{,*/}*.css'
  325.       }
  326.     },
  327.  
  328.     // Run some tasks in parallel to speed up the build process
  329.     concurrent: {
  330.       server: [
  331.         'copy:styles'
  332.       ],
  333.       test: [
  334.         'copy:styles'
  335.       ],
  336.       dist: [
  337.         'copy:styles',
  338.         'imagemin',
  339.         'svgmin'
  340.       ]
  341.     },
  342.  
  343.     // Test settings
  344.     karma: {
  345.       unit: {
  346.         configFile: 'test/config/karma.conf.js',
  347.         singleRun: true
  348.       }
  349.     },
  350.  
  351.     // e2e tests
  352.     protractor: {
  353.         options: {
  354.             keepAlive: false,
  355.             configFile: "test/config/protractor.conf.js",
  356.  
  357.             args: {
  358.                 seleniumServerJar: 'node_modules/protractor/selenium/selenium-server-standalone-2.39.0.jar',
  359.                 chromeDriver: 'node_modules/protractor/selenium/chromedriver.exe'
  360.             }
  361.         },
  362.         run: {
  363.  
  364.         }
  365.     },
  366.   });
  367.  
  368.  
  369.   grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  370.     if (target === 'dist') {
  371.       return grunt.task.run(['build', 'connect:dist:keepalive']);
  372.     }
  373.  
  374.     grunt.task.run([
  375.       'clean:server',
  376.       'wiredep',
  377.       'concurrent:server',
  378.       'autoprefixer',
  379.       'connect:livereload',
  380.       'watch'
  381.     ]);
  382.   });
  383.  
  384.   grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
  385.     grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  386.     grunt.task.run(['serve:' + target]);
  387.   });
  388.  
  389.   grunt.registerTask('test', [
  390.     'clean:server',
  391.     'concurrent:test',
  392.     'autoprefixer',
  393.     'connect:test',
  394.     // 'karma',
  395.     // Karma is configured to be used later but no tests have been made because it is not in specs
  396.     'protractor:run'
  397.   ]);
  398.  
  399.   grunt.registerTask('build', [
  400.     'clean:dist',
  401.     'wiredep',
  402.     'useminPrepare',
  403.     'concurrent:dist',
  404.     'autoprefixer',
  405.     'concat',
  406.     'ngAnnotate',
  407.     'copy:dist',
  408.     'cdnify',
  409.     'cssmin',
  410.     'uglify',
  411.     'filerev',
  412.     'usemin',
  413.     'htmlmin'
  414.   ]);
  415.  
  416.   grunt.registerTask('default', [
  417.     'newer:jshint',
  418.     'test',
  419.     'build'
  420.   ]);
  421. };
Advertisement
Add Comment
Please, Sign In to add comment