Guest User

Untitled

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