Advertisement
Guest User

Untitled

a guest
Aug 27th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Generated on 2014-08-05 using generator-angular 0.9.5
  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.       jsTest: {
  44.         files: ['test/spec/{,*/}*.js'],
  45.         tasks: ['newer:jshint:test', 'karma']
  46.       },
  47.       compass: {
  48.         files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
  49.         tasks: ['compass:server', '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.       options: {
  166.         cwd: '<%= yeoman.app %>'
  167.       },
  168.       app: {
  169.         src: ['<%= yeoman.app %>/index.html'],
  170.         ignorePath:  /\.\.\//
  171.       },
  172.       sass: {
  173.         src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
  174.         ignorePath: /(\.\.\/){1,2}bower_components\//
  175.       }
  176.     },
  177.  
  178.     // Compiles Sass to CSS and generates necessary files if requested
  179.     compass: {
  180.       options: {
  181.         sassDir: '<%= yeoman.app %>/styles',
  182.         cssDir: '.tmp/styles',
  183.         generatedImagesDir: '.tmp/images/generated',
  184.         imagesDir: '<%= yeoman.app %>/images',
  185.         javascriptsDir: '<%= yeoman.app %>/scripts',
  186.         fontsDir: '<%= yeoman.app %>/styles/fonts',
  187.         importPath: './bower_components',
  188.         httpImagesPath: '/images',
  189.         httpGeneratedImagesPath: '/images/generated',
  190.         httpFontsPath: '/styles/fonts',
  191.         relativeAssets: false,
  192.         assetCacheBuster: false,
  193.         raw: 'Sass::Script::Number.precision = 10\n'
  194.       },
  195.       dist: {
  196.         options: {
  197.           generatedImagesDir: '<%= yeoman.dist %>/images/generated'
  198.         }
  199.       },
  200.       server: {
  201.         options: {
  202.           debugInfo: true
  203.         }
  204.       }
  205.     },
  206.  
  207.     // Renames files for browser caching purposes
  208.     filerev: {
  209.       dist: {
  210.         src: [
  211.           '<%= yeoman.dist %>/scripts/{,*/}*.js',
  212.           '<%= yeoman.dist %>/styles/{,*/}*.css',
  213.           '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
  214.           '<%= yeoman.dist %>/styles/fonts/*'
  215.         ]
  216.       }
  217.     },
  218.  
  219.     // Reads HTML for usemin blocks to enable smart builds that automatically
  220.     // concat, minify and revision files. Creates configurations in memory so
  221.     // additional tasks can operate on them
  222.     useminPrepare: {
  223.       html: '<%= yeoman.app %>/index.html',
  224.       options: {
  225.         dest: '<%= yeoman.dist %>',
  226.         flow: {
  227.           html: {
  228.             steps: {
  229.               js: ['concat', 'uglifyjs'],
  230.               css: ['cssmin']
  231.             },
  232.             post: {}
  233.           }
  234.         }
  235.       }
  236.     },
  237.  
  238.     // Performs rewrites based on filerev and the useminPrepare configuration
  239.     usemin: {
  240.       html: ['<%= yeoman.dist %>/{,*/}*.html'],
  241.       css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
  242.       options: {
  243.         assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/images']
  244.       }
  245.     },
  246.  
  247.     // The following *-min tasks will produce minified files in the dist folder
  248.     // By default, your `index.html`'s <!-- Usemin block --> will take care of
  249.     // minification. These next options are pre-configured if you do not wish
  250.     // to use the Usemin blocks.
  251.     // cssmin: {
  252.     //   dist: {
  253.     //     files: {
  254.     //       '<%= yeoman.dist %>/styles/main.css': [
  255.     //         '.tmp/styles/{,*/}*.css'
  256.     //       ]
  257.     //     }
  258.     //   }
  259.     // },
  260.     // uglify: {
  261.     //   dist: {
  262.     //     files: {
  263.     //       '<%= yeoman.dist %>/scripts/scripts.js': [
  264.     //         '<%= yeoman.dist %>/scripts/scripts.js'
  265.     //       ]
  266.     //     }
  267.     //   }
  268.     // },
  269.     // concat: {
  270.     //   dist: {}
  271.     // },
  272.  
  273.     imagemin: {
  274.       dist: {
  275.         files: [{
  276.           expand: true,
  277.           cwd: '<%= yeoman.app %>/images',
  278.           src: '{,*/}*.{png,jpg,jpeg,gif}',
  279.           dest: '<%= yeoman.dist %>/images'
  280.         }]
  281.       }
  282.     },
  283.  
  284.     svgmin: {
  285.       dist: {
  286.         files: [{
  287.           expand: true,
  288.           cwd: '<%= yeoman.app %>/images',
  289.           src: '{,*/}*.svg',
  290.           dest: '<%= yeoman.dist %>/images'
  291.         }]
  292.       }
  293.     },
  294.  
  295.     htmlmin: {
  296.       dist: {
  297.         options: {
  298.           collapseWhitespace: true,
  299.           conservativeCollapse: true,
  300.           collapseBooleanAttributes: true,
  301.           removeCommentsFromCDATA: true,
  302.           removeOptionalTags: true
  303.         },
  304.         files: [{
  305.           expand: true,
  306.           cwd: '<%= yeoman.dist %>',
  307.           src: ['*.html', 'views/{,*/}*.html', 'templates/{,*/}*.html'],
  308.           dest: '<%= yeoman.dist %>'
  309.         }]
  310.       }
  311.     },
  312.  
  313.     // ngmin tries to make the code safe for minification automatically by
  314.     // using the Angular long form for dependency injection. It doesn't work on
  315.     // things like resolve or inject so those have to be done manually.
  316.     ngmin: {
  317.       dist: {
  318.         files: [{
  319.           expand: true,
  320.           cwd: '.tmp/concat/scripts',
  321.           src: '*.js',
  322.           dest: '.tmp/concat/scripts'
  323.         }]
  324.       }
  325.     },
  326.  
  327.     // Replace Google CDN references
  328.     cdnify: {
  329.       dist: {
  330.         html: ['<%= yeoman.dist %>/*.html']
  331.       }
  332.     },
  333.  
  334.     // Copies remaining files to places other tasks can use
  335.     copy: {
  336.       dist: {
  337.         files: [{
  338.           expand: true,
  339.           dot: true,
  340.           cwd: '<%= yeoman.app %>',
  341.           dest: '<%= yeoman.dist %>',
  342.           src: [
  343.             '*.{ico,png,txt}',
  344.             '.htaccess',
  345.             '*.html',
  346.             'views/{,*/}*.html',
  347.             'templates/{,*/}*.html',
  348.             'images/{,*/}*.{webp}',
  349.             'fonts/*'
  350.           ]
  351.         }, {
  352.           expand: true,
  353.           cwd: '.tmp/images',
  354.           dest: '<%= yeoman.dist %>/images',
  355.           src: ['generated/*']
  356.         }, {
  357.           // bootstrap fonts
  358.           expand: true,
  359.           cwd: '.',
  360.           src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*',
  361.           dest: '<%= yeoman.dist %>'
  362.         }, {
  363.           // font awesome
  364.           expand: true,
  365.           dot: true,
  366.           cwd: 'bower_components/font-awesome',
  367.           src: ['fonts/*.*'],
  368.           dest: '<%= yeoman.dist %>'
  369.         }]
  370.       },
  371.       styles: {
  372.         expand: true,
  373.         cwd: '<%= yeoman.app %>/styles',
  374.         dest: '.tmp/styles/',
  375.         src: '{,*/}*.css'
  376.       }
  377.     },
  378.  
  379.     // Run some tasks in parallel to speed up the build process
  380.     concurrent: {
  381.       server: [
  382.         'compass:server'
  383.       ],
  384.       test: [
  385.         'compass'
  386.       ],
  387.       dist: [
  388.         'compass:dist',
  389.         'imagemin',
  390.         'svgmin'
  391.       ]
  392.     },
  393.  
  394.     // Test settings
  395.     karma: {
  396.       unit: {
  397.         configFile: 'test/karma.conf.js',
  398.         singleRun: true
  399.       }
  400.     }
  401.   });
  402.  
  403.  
  404.   grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
  405.     if (target === 'dist') {
  406.       return grunt.task.run(['build', 'connect:dist:keepalive']);
  407.     }
  408.  
  409.     grunt.task.run([
  410.       'clean:server',
  411.       'wiredep',
  412.       'concurrent:server',
  413.       'autoprefixer',
  414.       'connect:livereload',
  415.       'watch'
  416.     ]);
  417.   });
  418.  
  419.   grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
  420.     grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
  421.     grunt.task.run(['serve:' + target]);
  422.   });
  423.  
  424.   grunt.registerTask('test', [
  425.     'clean:server',
  426.     'concurrent:test',
  427.     'autoprefixer',
  428.     'connect:test',
  429.     'karma'
  430.   ]);
  431.  
  432.   grunt.registerTask('build', [
  433.     'clean:dist',
  434.     'wiredep',
  435.     'useminPrepare',
  436.     'concurrent:dist',
  437.     'autoprefixer',
  438.     'concat',
  439.     'ngmin',
  440.     'copy:dist',
  441.     'cdnify',
  442.     'cssmin',
  443.     'uglify',
  444.     'filerev',
  445.     'usemin',
  446.     'htmlmin'
  447.   ]);
  448.  
  449.   grunt.registerTask('default', [
  450.     'newer:jshint',
  451.     'test',
  452.     'build'
  453.   ]);
  454. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement