Guest User

Untitled

a guest
Aug 31st, 2015
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Generated on 2015-01-06 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. var modRewrite = require('connect-modrewrite');
  11.  
  12. module.exports = function (grunt) {
  13.  
  14.     // Load grunt tasks automatically
  15.     require('load-grunt-tasks')(grunt);
  16.    
  17.     // Time how long tasks take. Can help when optimizing build times
  18.     require('time-grunt')(grunt);
  19.  
  20.     // Configurable paths for the application
  21.     var appConfig = {
  22.         app: require('./bower.json').appPath || '.',
  23.         dist: 'dist'
  24.     };
  25.  
  26.     // Define the configuration for all the tasks
  27.     grunt.initConfig({
  28.  
  29.         // Project settings
  30.         yeoman: appConfig,
  31.  
  32.         // Watches files for changes and runs tasks based on the changed files
  33.         watch: {
  34.             options: {
  35.                 livereload: true,
  36.             },
  37.             bower: {
  38.                 files: ['bower.json'],
  39.                 tasks: ['wiredep']
  40.             },
  41.             js: {
  42.                 files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
  43.                 tasks: ['newer:jshint:all'],
  44.                 options: {
  45.                     livereload: '<%= connect.options.livereload %>'
  46.                 }
  47.             },
  48.             jsTest: {
  49.                 files: ['test/spec/{,*/}*.js'],
  50.                 tasks: ['newer:jshint:test', 'karma']
  51.             },
  52.             compass: {
  53.                 files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
  54.             },
  55.             css: {
  56.                 files: ['<%= yeoman.app %>/styles/{,*/}*.{css}'],
  57.                 tasks: []
  58.             },
  59.             gruntfile: {
  60.                 files: ['Gruntfile.js']
  61.             },
  62.             livereload: {
  63.                 options: {
  64.                     livereload: '<%= connect.options.livereload %>'
  65.                 },
  66.                 files: [
  67.                     '<%= yeoman.app %>/{,*/}*.html',
  68.                     '.tmp/styles/{,*/}*.css',
  69.                     '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  70.                 ]
  71.             }
  72.         },
  73.  
  74.         // The actual grunt server settings
  75.         connect: {
  76.             options: {
  77.                 port: 9000,
  78.                 // Change this to '0.0.0.0' to access the server from outside.
  79.                 hostname: 'localhost',
  80.                 livereload: 35729
  81.             },
  82.             livereload: {
  83.                 options: {
  84.                     open: true,
  85.                     middleware: function (connect) {
  86.                         return [
  87.                             connect().use(
  88.                                 modRewrite(['^/Home$ /#/Home [L]',
  89.                                 '^/Home/\\d*$ /#/Home [L]',
  90.                                 '^/EventReport$ /#/EventReport [L]',
  91.                                 '^/EventReport/$ /#/EventReport [L]',
  92.                                 '^/EventReport/(.*)$ /#/EventReport/$1 [L]',
  93.  
  94.  
  95.                                 '^/ProjectOverview$ /#/ProjectOverview [L]',
  96.                                 '^/ProjectOverview/$ /#/ProjectOverview [L]',
  97.                                 '^/ProjectOverviews/(.*)$ /#/ProjectOverviews/$1 [L]'
  98.                             ])
  99.                         ),
  100.                         connect.static('.tmp'),
  101.                         connect().use(
  102.                             '/bower_components',
  103.                             connect.static('./bower_components')
  104.                         ),
  105.                         connect.static(appConfig.app)
  106.                     ];
  107.                 }
  108.             }
  109.         },
  110.         test: {
  111.             options: {
  112.                 port: 9001,
  113.                 middleware: function (connect) {
  114.                     return [
  115.                         connect.static('.tmp'),
  116.                         connect.static('test'),
  117.                         connect().use(
  118.                             '/bower_components',
  119.                             connect.static('./bower_components')
  120.                         ),
  121.                         connect.static(appConfig.app)
  122.                     ];
  123.                 }
  124.             }
  125.         },
  126.         dist: {
  127.             options: {
  128.                 open: true,
  129.                 base: '<%= yeoman.dist %>'
  130.             }
  131.         }
  132.     },
  133.  
  134.     // Make sure code styles are up to par and there are no obvious mistakes
  135.     jshint: {
  136.         options: {
  137.             jshintrc: '.jshintrc',
  138.             reporter: require('jshint-stylish')
  139.         },
  140.         all: {
  141.             src: [
  142.                 'Gruntfile.js',
  143.                 '<%= yeoman.app %>/scripts/{,*/}*.js'
  144.             ]
  145.         },
  146.         test: {
  147.             options: {
  148.                 jshintrc: 'test/.jshintrc'
  149.             },
  150.             src: ['test/spec/{,*/}*.js']
  151.         }
  152.     },
  153.  
  154.     // Empties folders to start fresh
  155.     clean: {
  156.         dist: {
  157.             files: [{
  158.                 dot: true,
  159.                 src: [
  160.                     '.tmp',
  161.                     '<%= yeoman.dist %>/{,*/}*',
  162.                     '!<%= yeoman.dist %>/.git{,*/}*'
  163.                 ]
  164.             }]
  165.         },
  166.         server: '.tmp'
  167.     },
  168.  
  169.     // Add vendor prefixed styles
  170.     autoprefixer: {
  171.         options: {
  172.             browsers: ['last 1 version']
  173.         },
  174.         dist: {
  175.             files: [{
  176.                 expand: true,
  177.                 cwd: '.tmp/styles/',
  178.                 src: '{,*/}*.css',
  179.                 dest: '.tmp/styles/'
  180.             }]
  181.         }
  182.     },
  183.  
  184.     // Automatically inject Bower components into the app
  185.     wiredep: {
  186.         app: {
  187.             src: ['<%= yeoman.app %>/index.html'],
  188.             ignorePath:  /\.\.\//
  189.         },
  190.         sass: {
  191.             src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
  192.             ignorePath: /(\.\.\/){1,2}bower_components\//
  193.         }
  194.     },
  195.  
  196.     sass: {
  197.         dist: {
  198.             files: [{
  199.                 expand: true,
  200.                 cwd: '<%= yeoman.app %>/styles',
  201.                 src: ['*.scss'],
  202.                 dest: '<%= yeoman.app %>/styles',
  203.                 ext: '.css'
  204.             }]
  205.         }
  206.     },
  207.  
  208.     // Compiles Sass to CSS and generates necessary files if requested
  209.     compass: {
  210.         options: {
  211.             sassDir: '<%= yeoman.app %>/styles',
  212.             cssDir: '.tmp/styles',
  213.             generatedImagesDir: '.tmp/images/generated',
  214.             imagesDir: '<%= yeoman.app %>/images',
  215.             javascriptsDir: '<%= yeoman.app %>/scripts',
  216.             fontsDir: '<%= yeoman.app %>/styles/fonts',
  217.             importPath: './bower_components',
  218.             httpImagesPath: '/images',
  219.             httpGeneratedImagesPath: '/images/generated',
  220.             httpFontsPath: '/styles/fonts',
  221.             relativeAssets: false,
  222.             assetCacheBuster: false,
  223.             raw: 'Sass::Script::Number.precision = 10\n'
  224.         },
  225.         dist: {
  226.             options: {
  227.                 generatedImagesDir: '<%= yeoman.dist %>/images/generated'
  228.             }
  229.         },
  230.         server: {
  231.             options: {
  232.                 debugInfo: true
  233.             }
  234.         }
  235.     },
  236.  
  237.     // Renames files for browser caching purposes
  238.     filerev: {
  239.         dist: {
  240.             src: [
  241.                 '<%= yeoman.dist %>/scripts/{,*/}*.js',
  242.                 '<%= yeoman.dist %>/styles/{,*/}*.css',
  243.                 '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  244.                 '<%= yeoman.dist %>/styles/fonts/*'
  245.             ]
  246.         }
  247.     },
  248.  
  249.     // Reads HTML for usemin blocks to enable smart builds that automatically
  250.     // concat, minify and revision files. Creates configurations in memory so
  251.     // additional tasks can operate on them
  252.     useminPrepare: {
  253.         html: '<%= yeoman.app %>/index.html',
  254.         options: {
  255.             dest: '<%= yeoman.dist %>',
  256.             flow: {
  257.                 html: {
  258.                     steps: {
  259.                         js: ['concat', 'uglifyjs'],
  260.                         css: ['cssmin']
  261.                     },
  262.                     post: {}
  263.                 }
  264.             }
  265.         }
  266.     },
  267.  
  268.     // Performs rewrites based on filerev and the useminPrepare configuration
  269.     usemin: {
  270.         html: ['<%= yeoman.dist %>/{,*/}*.html'],
  271.         css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  272.         options: {
  273.             assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
  274.         }
  275.     },
  276.  
  277.     // The following *-min tasks will produce minified files in the dist folder
  278.     // By default, your `index.html`'s <!-- Usemin block --> will take care of
  279.     // minification. These next options are pre-configured if you do not wish
  280.     // to use the Usemin blocks.
  281.     // cssmin: {
  282.     //   dist: {
  283.     //     files: {
  284.     //       '<%= yeoman.dist %>/styles/main.css': [
  285.     //         '.tmp/styles/{,*/}*.css'
  286.     //       ]
  287.     //     }
  288.     //   }
  289.     // },
  290.     // uglify: {
  291.     //   dist: {
  292.     //     files: {
  293.     //       '<%= yeoman.dist %>/scripts/scripts.js': [
  294.     //         '<%= yeoman.dist %>/scripts/scripts.js'
  295.     //       ]
  296.     //     }
  297.     //   }
  298.     // },
  299.     // concat: {
  300.     //   dist: {}
  301.     // },
  302.  
  303.     imagemin: {
  304.         dist: {
  305.             files: [{
  306.                 expand: true,
  307.                 cwd: '<%= yeoman.app %>/images',
  308.                 src: '{,*/}*.{png,jpg,jpeg,gif}',
  309.                 dest: '<%= yeoman.dist %>/images'
  310.             }]
  311.         }
  312.     },
  313.  
  314.     svgmin: {
  315.         dist: {
  316.             files: [{
  317.                 expand: true,
  318.                 cwd: '<%= yeoman.app %>/images',
  319.                 src: '{,*/}*.svg',
  320.                 dest: '<%= yeoman.dist %>/images'
  321.             }]
  322.         }
  323.     },
  324.  
  325.     htmlmin: {
  326.         dist: {
  327.             options: {
  328.                 collapseWhitespace: true,
  329.                 conservativeCollapse: true,
  330.                 collapseBooleanAttributes: true,
  331.                 removeCommentsFromCDATA: true,
  332.                 removeOptionalTags: true
  333.             },
  334.             files: [{
  335.                 expand: true,
  336.                 cwd: '<%= yeoman.dist %>',
  337.                 src: ['*.html', 'views/{,*/}*.html'],
  338.                 dest: '<%= yeoman.dist %>'
  339.             }]
  340.         }
  341.     },
  342.  
  343.     // ng-annotate tries to make the code safe for minification automatically
  344.     // by using the Angular long form for dependency injection.
  345.     ngAnnotate: {
  346.         dist: {
  347.             files: [{
  348.                 expand: true,
  349.                 cwd: '.tmp/concat/scripts',
  350.                 src: ['*.js', '!oldieshim.js'],
  351.                 dest: '.tmp/concat/scripts'
  352.             }]
  353.         }
  354.     },
  355.  
  356.     // Replace Google CDN references
  357.     cdnify: {
  358.         dist: {
  359.             html: ['<%= yeoman.dist %>/index.html']
  360.         }
  361.     },
  362.  
  363.     // Copies remaining files to places other tasks can use
  364.     copy: {
  365.         dist: {
  366.             files: [{
  367.                 expand: true,
  368.                 dot: true,
  369.                 cwd: '<%= yeoman.app %>',
  370.                 dest: '<%= yeoman.dist %>',
  371.                 src: [
  372.                     '*.{ico,png,txt}',
  373.                     '.htaccess',
  374.                     '*.html',
  375.                     'views/{,*/}*.html',
  376.                     'images/{,*/}*.{webp}',
  377.                     'fonts/{,*/}*.*'
  378.                 ]
  379.             }, {
  380.                 expand: true,
  381.                 cwd: '.tmp/images',
  382.                 dest: '<%= yeoman.dist %>/images',
  383.                 src: ['generated/*']
  384.             }, {
  385.                 expand: true,
  386.                 cwd: 'bower_components/bootstrap/dist',
  387.                 src: 'fonts/*',
  388.                 dest: '<%= yeoman.dist %>'
  389.             }]
  390.         },
  391.         styles: {
  392.             expand: true,
  393.             cwd: '<%= yeoman.app %>/styles',
  394.             dest: '.tmp/styles/',
  395.             src: '{,*/}*.css'
  396.         }
  397.     },
  398.  
  399.     // Run some tasks in parallel to speed up the build process
  400.     concurrent: {
  401.         server: [
  402.             'compass:server'
  403.         ],
  404.         test: [
  405.             'compass'
  406.         ],
  407.         dist: [
  408.             'compass:dist',
  409.             'imagemin',
  410.             'svgmin'
  411.         ]
  412.     },
  413.  
  414.     // Test settings
  415.     karma: {
  416.         unit: {
  417.             configFile: 'test/karma.conf.js',
  418.             singleRun: true
  419.         }
  420.     }
  421. });
  422.  
  423.  
  424. grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  425.     if (target === 'dist') {
  426.         return grunt.task.run(['build', 'connect:dist:keepalive']);
  427.     }
  428.  
  429.     grunt.task.run([
  430.         'clean:server',
  431.         'wiredep',
  432.         'concurrent:server',
  433.         'autoprefixer',
  434.         'connect:livereload',
  435.         'watch'
  436.     ]);
  437. });
  438.  
  439. grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
  440.     grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  441.     grunt.task.run(['serve:' + target]);
  442. });
  443.  
  444. grunt.registerTask('test', [
  445.     'clean:server',
  446.     'concurrent:test',
  447.     'autoprefixer',
  448.     'connect:test',
  449.     'karma'
  450. ]);
  451.  
  452. grunt.registerTask('build', [
  453.     'clean:dist',
  454.     'wiredep',
  455.     'useminPrepare',
  456.     'concurrent:dist',
  457.     'autoprefixer',
  458.     'concat',
  459.     'ngAnnotate',
  460.     'copy:dist',
  461.     'cdnify',
  462.     'cssmin',
  463.     'uglify',
  464.     'filerev',
  465.     'usemin',
  466.     'htmlmin'
  467. ]);
  468.  
  469. grunt.registerTask('default', [
  470.     'newer:jshint',
  471.     'test',
  472.     'build',
  473.     'sass'
  474. ]);
  475.  
  476. grunt.loadNpmTasks('grunt-favicons');
  477. grunt.loadNpmTasks('grunt-contrib-sass');
  478. grunt.loadNpmTasks('grunt-contrib-compass');
  479. };
Advertisement
Add Comment
Please, Sign In to add comment