Advertisement
Guest User

Untitled

a guest
Mar 9th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Generated on 2014-11-05 using generator-angular 0.9.8
  2. 'use strict'
  3. # # Globbing
  4. # for performance reasons we're only matching one level down:
  5. # 'test/spec/{,*/}*.js'
  6. # use this if you want to recursively match all subfolders:
  7. # 'test/spec/**/*.js'
  8.  
  9. module.exports = (grunt) ->
  10.   # Load grunt tasks automatically
  11.   require('load-grunt-tasks') grunt
  12.   # Time how long tasks take. Can help when optimizing build times
  13.   require('time-grunt') grunt
  14.   # Configurable paths for the application
  15.   appConfig =
  16.     app: require('./bower.json').appPath or 'app'
  17.     dist: '../public'
  18.   modRewrite = require('connect-modrewrite')
  19.  
  20.   # Define the configuration for all the tasks
  21.   grunt.initConfig
  22.     yeoman: appConfig
  23.     watch:
  24.       bower:
  25.         files: [ 'bower.json' ]
  26.         tasks: [ 'wiredep' ]
  27.       js:
  28.         files: [ '<%= yeoman.app %>/scripts/{,*/}*.js' ]
  29.         tasks: [ 'newer:jshint:all' ]
  30.         options: livereload: '<%= connect.options.livereload %>'
  31.       jade:
  32.         files: ['<%= yeoman.app %>/{,*/}*.jade'],
  33.         tasks: ['jade']
  34.       coffee:
  35.         files: [ '<%= yeoman.app %>/scripts/{,*/}*.{coffee,litcoffee,coffee.md}' ]
  36.         tasks: [ 'newer:coffee:dist']
  37.       jsTest:
  38.         files: [ 'test/spec/{,*/}*.js' ]
  39.         tasks: [
  40.           'newer:jshint:test'
  41.           'karma'
  42.         ]
  43.       compass:
  44.         files: [ '<%= yeoman.app %>/styles/{,*/}*.{scss,sass}' ]
  45.         tasks: [
  46.           'compass:server'
  47.           'autoprefixer'
  48.         ]
  49.       gruntfile: files: [ 'Gruntfile.js' ]
  50.       livereload:
  51.         options: livereload: '<%= connect.options.livereload %>'
  52.         files: [
  53.           '<%= yeoman.app %>/{,*/}*.html'
  54.           '.tmp/styles/{,*/}*.css'
  55.           '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  56.         ]
  57.     connect:
  58.       options:
  59.         port: 9000
  60.         hostname: 'localhost'
  61.         livereload: 35729
  62.       proxies: [ {
  63.         context: '/api'
  64.         host: 'localhost'
  65.         port: 3000
  66.       } ]
  67.       livereload: options:
  68.         open: true
  69.         middleware: (connect, options) ->
  70.           if !Array.isArray(options.base)
  71.             options.base = [ options.base ]
  72.           middlewares = [
  73.             modRewrite([ '!/api|/assets|\\..+$ /index.html' ])
  74.             require('grunt-connect-proxy/lib/utils').proxyRequest
  75.             connect.static('.tmp')
  76.             connect().use('/bower_components', connect.static('./bower_components'))
  77.             connect.static(appConfig.app)
  78.           ]
  79.           # Make directory browse-able.
  80.           directory = options.directory or options.base[options.base.length - 1]
  81.           middlewares.push connect.directory(directory)
  82.           middlewares
  83.       test: options:
  84.         port: 9001
  85.         middleware: (connect) ->
  86.           [
  87.             connect.static('.tmp')
  88.             connect.static('test')
  89.             connect().use('/bower_components', connect.static('./bower_components'))
  90.             connect.static(appConfig.app)
  91.           ]
  92.       dist: options:
  93.         open: true
  94.         base: '<%= yeoman.dist %>'
  95.     jshint:
  96.       options:
  97.         jshintrc: '.jshintrc'
  98.         reporter: require('jshint-stylish')
  99.       all: src: [
  100.         'Gruntfile.js'
  101.         '<%= yeoman.app %>/scripts/{,*/}*.js'
  102.       ]
  103.       test:
  104.         options: jshintrc: 'test/.jshintrc'
  105.         src: [ 'test/spec/{,*/}*.js' ]
  106.     clean:
  107.       dist: files: [ {
  108.         dot: true
  109.         src: [
  110.           '.tmp'
  111.           '<%= yeoman.dist %>/{,*/}*'
  112.           '!<%= yeoman.dist %>/.git*'
  113.         ]
  114.       } ]
  115.       server: '.tmp'
  116.     autoprefixer:
  117.       options: browsers: [ 'last 1 version' ]
  118.       dist: files: [ {
  119.         expand: true
  120.         cwd: '.tmp/styles/'
  121.         src: '{,*/}*.css'
  122.         dest: '.tmp/styles/'
  123.       } ]
  124.     wiredep:
  125.       app:
  126.         src: [ '<%= yeoman.app %>/index.html' ]
  127.         ignorePath: /\.\.\//
  128.       sass:
  129.         src: [ '<%= yeoman.app %>/styles/{,*/}*.{scss,sass}' ]
  130.         ignorePath: /(\.\.\/){1,2}bower_components\//
  131.     jade:
  132.       dist:
  133.         options:
  134.           pretty: true
  135.           data:
  136.             debug: true
  137.         files: [
  138.           expand: true
  139.           cwd: '<%= yeoman.app %>'
  140.           dest: '.tmp'
  141.           src: '**/*.jade'
  142.           ext: '.html'
  143.         ]
  144.     coffee:
  145.       options:
  146.         sourceMap: true
  147.         bare: true
  148.         sourceRoot: ''
  149.       dist:
  150.         files: [
  151.           expand: true
  152.           cwd: '<%= yeoman.app %>/scripts'
  153.           src: '{,*/}*.coffee'
  154.           dest: '.tmp/scripts'
  155.           ext: '.js'
  156.         ]
  157.       test:
  158.         files: [
  159.           expand: true
  160.           cwd: 'test/spec'
  161.           src: '{,*/}*.coffee'
  162.           dest: '.tmp/spec'
  163.           ext: '.js'
  164.         ]
  165.     compass:
  166.       options:
  167.         sassDir: '<%= yeoman.app %>/styles'
  168.         cssDir: '.tmp/styles'
  169.         generatedImagesDir: '.tmp/images/generated'
  170.         imagesDir: '<%= yeoman.app %>/images'
  171.         javascriptsDir: '<%= yeoman.app %>/scripts'
  172.         fontsDir: '<%= yeoman.app %>/styles/fonts'
  173.         importPath: './bower_components'
  174.         httpImagesPath: '/images'
  175.         httpGeneratedImagesPath: '/images/generated'
  176.         httpFontsPath: '/styles/fonts'
  177.         relativeAssets: false
  178.         assetCacheBuster: false
  179.         raw: 'Sass::Script::Number.precision = 10\n'
  180.       dist: options: generatedImagesDir: '<%= yeoman.dist %>/images/generated'
  181.       server: options: debugInfo: true
  182.     filerev: dist: src: [
  183.       '<%= yeoman.dist %>/scripts/{,*/}*.js'
  184.       '<%= yeoman.dist %>/styles/{,*/}*.css'
  185.       '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  186.       '<%= yeoman.dist %>/styles/fonts/*'
  187.     ]
  188.     useminPrepare:
  189.       html: '<%= yeoman.app %>/index.html'
  190.       options:
  191.         dest: '<%= yeoman.dist %>'
  192.         flow: html:
  193.           steps:
  194.             js: [
  195.               'concat'
  196.               'uglifyjs'
  197.             ]
  198.             css: [ 'cssmin' ]
  199.           post: {}
  200.     usemin:
  201.       html: [ '<%= yeoman.dist %>/{,*/}*.html' ]
  202.       css: [ '<%= yeoman.dist %>/styles/{,*/}*.css' ]
  203.       options: assetsDirs: [
  204.         '<%= yeoman.dist %>'
  205.         '<%= yeoman.dist %>/images'
  206.       ]
  207.     imagemin: dist: files: [ {
  208.       expand: true
  209.       cwd: '<%= yeoman.app %>/images'
  210.       src: '{,*/}*.{png,jpg,jpeg,gif}'
  211.       dest: '<%= yeoman.dist %>/images'
  212.     } ]
  213.     svgmin: dist: files: [ {
  214.       expand: true
  215.       cwd: '<%= yeoman.app %>/images'
  216.       src: '{,*/}*.svg'
  217.       dest: '<%= yeoman.dist %>/images'
  218.     } ]
  219.     htmlmin: dist:
  220.       options:
  221.         collapseWhitespace: true
  222.         conservativeCollapse: true
  223.         collapseBooleanAttributes: true
  224.         removeCommentsFromCDATA: true
  225.         removeOptionalTags: true
  226.       files: [ {
  227.         expand: true
  228.         cwd: '<%= yeoman.dist %>'
  229.         src: [
  230.           '*.html'
  231.           'views/{,*/}*.html'
  232.         ]
  233.         dest: '<%= yeoman.dist %>'
  234.       } ]
  235.     ngAnnotate: dist: files: [ {
  236.       expand: true
  237.       cwd: '.tmp/concat/scripts'
  238.       src: [
  239.         '*.js'
  240.         '!oldieshim.js'
  241.       ]
  242.       dest: '.tmp/concat/scripts'
  243.     } ]
  244.     cdnify: dist: html: [ '<%= yeoman.dist %>/*.html' ]
  245.     copy:
  246.       dist: files: [
  247.         {
  248.           expand: true
  249.           dot: true
  250.           cwd: '<%= yeoman.app %>'
  251.           dest: '<%= yeoman.dist %>'
  252.           src: [
  253.             '*.{ico,png,txt}'
  254.             '.htaccess'
  255.             '*.html'
  256.             'views/{,*/}*.html'
  257.             'images/{,*/}*.{webp}'
  258.             'fonts/*'
  259.           ]
  260.         }
  261.         {
  262.           expand: true
  263.           cwd: '.tmp/images'
  264.           dest: '<%= yeoman.dist %>/images'
  265.           src: [ 'generated/*' ]
  266.         }
  267.         {
  268.           expand: true
  269.           cwd: '.'
  270.           src: 'bower_components/bootstrap-sass-official/assets/fonts/bootstrap/*'
  271.           dest: '<%= yeoman.dist %>'
  272.         }
  273.       ]
  274.       styles:
  275.         expand: true
  276.         cwd: '<%= yeoman.app %>/styles'
  277.         dest: '.tmp/styles/'
  278.         src: '{,*/}*.css'
  279.     concurrent:
  280.       server: [
  281.         'jade'
  282.         'coffee:dist'
  283.         'compass:server'
  284.       ]
  285.       test: [ 'compass' ]
  286.       dist: [
  287.         'jade'
  288.         'coffee'
  289.         'compass:dist'
  290.         'imagemin'
  291.         'svgmin'
  292.       ]
  293.     karma: unit:
  294.       configFile: 'test/karma.conf.js'
  295.       singleRun: true
  296.   grunt.registerTask 'serve', 'Compile then start a connect web server', (target) ->
  297.     if target == 'dist'
  298.       return grunt.task.run([
  299.         'build'
  300.         'connect:dist:keepalive'
  301.       ])
  302.     grunt.task.run [
  303.       'clean:server'
  304.       'wiredep'
  305.       'railsServer:development'
  306.       'concurrent:server'
  307.       'autoprefixer'
  308.       'configureProxies'
  309.       'connect:livereload'
  310.       'watch'
  311.     ]
  312.     return
  313.   grunt.registerTask 'server', 'DEPRECATED TASK. Use the "serve" task instead', (target) ->
  314.     grunt.log.warn 'The `server` task has been deprecated. Use `grunt serve` to start a server.'
  315.     grunt.task.run [ 'serve:' + target ]
  316.     return
  317.   grunt.registerTask 'test', [
  318.     'clean:server'
  319.     'concurrent:test'
  320.     'autoprefixer'
  321.     'connect:test'
  322.     'karma'
  323.   ]
  324.   grunt.registerTask 'build', [
  325.     'clean:dist'
  326.     'jade'
  327.     'coffee'
  328.     'wiredep'
  329.     'useminPrepare'
  330.     'concurrent:dist'
  331.     'autoprefixer'
  332.     'concat'
  333.     'ngAnnotate'
  334.     'copy:dist'
  335.     'cdnify'
  336.     'cssmin'
  337.     'uglify'
  338.     'filerev'
  339.     'usemin'
  340.     'htmlmin'
  341.   ]
  342.   grunt.registerTask 'default', [
  343.     'newer:jshint'
  344.     'test'
  345.     'build'
  346.   ]
  347.  
  348.   grunt.registerTask 'heroku:production', 'build'
  349.  
  350.   grunt.loadNpmTasks 'grunt-contrib-jade'
  351.   grunt.loadNpmTasks 'grunt-contrib-coffee'
  352.   grunt.loadNpmTasks 'grunt-connect-proxy'
  353.   grunt.loadNpmTasks 'grunt-rails-server'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement