github.com/kula/etcd@v0.2.1-0.20131226070625-e96234382ac0/mod/dashboard/Gruntfile.js (about)

     1  // Generated on 2013-10-07 using generator-webapp 0.4.3
     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      // show elapsed time at the end
    12      require('time-grunt')(grunt);
    13      // load all grunt tasks
    14      require('load-grunt-tasks')(grunt);
    15  
    16      grunt.initConfig({
    17          // configurable paths
    18          uglify: {
    19            options: {
    20              mangle: false
    21            },
    22          },
    23          yeoman: {
    24              app: 'app',
    25              dist: 'dist'
    26          },
    27          watch: {
    28              compass: {
    29                  files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
    30                  tasks: ['compass:server', 'autoprefixer']
    31              },
    32              styles: {
    33                  files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
    34                  tasks: ['copy:styles', 'autoprefixer']
    35              },
    36              livereload: {
    37                  options: {
    38                      livereload: '<%= connect.options.livereload %>'
    39                  },
    40                  files: [
    41                      '<%= yeoman.app %>/*.html',
    42                      '.tmp/styles/{,*/}*.css',
    43                      '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
    44                      '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
    45                  ]
    46              }
    47          },
    48          connect: {
    49              options: {
    50                  port: 9000,
    51                  livereload: 35729,
    52                  // change this to '0.0.0.0' to access the server from outside
    53                  hostname: 'localhost'
    54              },
    55              livereload: {
    56                  options: {
    57                      open: true,
    58                      base: [
    59                          '.tmp',
    60                          '<%= yeoman.app %>'
    61                      ]
    62                  }
    63              },
    64              test: {
    65                  options: {
    66                      base: [
    67                          '.tmp',
    68                          'test',
    69                          '<%= yeoman.app %>'
    70                      ]
    71                  }
    72              },
    73              dist: {
    74                  options: {
    75                      open: true,
    76                      base: '<%= yeoman.dist %>'
    77                  }
    78              }
    79          },
    80          clean: {
    81              dist: {
    82                  files: [{
    83                      dot: true,
    84                      src: [
    85                          '.tmp',
    86                          '<%= yeoman.dist %>/*',
    87                          '!<%= yeoman.dist %>/.git*'
    88                      ]
    89                  }]
    90              },
    91              server: '.tmp'
    92          },
    93          jshint: {
    94              options: {
    95                  jshintrc: '.jshintrc'
    96              },
    97              all: [
    98                  '<%= yeoman.app %>/scripts/{,*/}*.js',
    99                  '!<%= yeoman.app %>/scripts/vendor/*',
   100              ]
   101          },
   102          mocha: {
   103              all: {
   104                  options: {
   105                      run: true,
   106                      urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html']
   107                  }
   108              }
   109          },
   110          compass: {
   111              options: {
   112                  sassDir: '<%= yeoman.app %>/styles',
   113                  cssDir: '.tmp/styles',
   114                  generatedImagesDir: '.tmp/images/generated',
   115                  imagesDir: '<%= yeoman.app %>/images',
   116                  javascriptsDir: '<%= yeoman.app %>/scripts',
   117                  fontsDir: '<%= yeoman.app %>/styles/fonts',
   118                  importPath: '<%= yeoman.app %>/bower_components',
   119                  httpImagesPath: '/images',
   120                  httpGeneratedImagesPath: '/images/generated',
   121                  httpFontsPath: '/styles/fonts',
   122                  relativeAssets: false,
   123                  assetCacheBuster: false
   124              },
   125              dist: {
   126                  options: {
   127                      generatedImagesDir: '<%= yeoman.dist %>/images/generated'
   128                  }
   129              },
   130              server: {
   131                  options: {
   132                      debugInfo: true
   133                  }
   134              }
   135          },
   136          autoprefixer: {
   137              options: {
   138                  browsers: ['last 1 version']
   139              },
   140              dist: {
   141                  files: [{
   142                      expand: true,
   143                      cwd: '.tmp/styles/',
   144                      src: '{,*/}*.css',
   145                      dest: '.tmp/styles/'
   146                  }]
   147              }
   148          },
   149          // not used since Uglify task does concat,
   150          // but still available if needed
   151          /*concat: {
   152              dist: {}
   153          },*/
   154          requirejs: {
   155              dist: {
   156                  // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
   157                  options: {
   158                      // `name` and `out` is set by grunt-usemin
   159                      baseUrl: '<%= yeoman.app %>/scripts',
   160                      optimize: 'none',
   161                      // TODO: Figure out how to make sourcemaps work with grunt-usemin
   162                      // https://github.com/yeoman/grunt-usemin/issues/30
   163                      //generateSourceMaps: true,
   164                      // required to support SourceMaps
   165                      // http://requirejs.org/docs/errors.html#sourcemapcomments
   166                      preserveLicenseComments: false,
   167                      useStrict: true,
   168                      wrap: true
   169                      //uglify2: {} // https://github.com/mishoo/UglifyJS2
   170                  }
   171              }
   172          },
   173          useminPrepare: {
   174              options: {
   175                  dest: '<%= yeoman.dist %>'
   176              },
   177              html: ['<%= yeoman.app %>/**/*.html']
   178          },
   179          usemin: {
   180              options: {
   181                  dirs: ['<%= yeoman.dist %>']
   182              },
   183              html: ['<%= yeoman.dist %>/{,*/}*.html'],
   184              css: ['<%= yeoman.dist %>/styles/{,*/}*.css']
   185          },
   186          imagemin: {
   187              dist: {
   188                  files: [{
   189                      expand: true,
   190                      cwd: '<%= yeoman.app %>/images',
   191                      src: '{,*/}*.{png,jpg,jpeg}',
   192                      dest: '<%= yeoman.dist %>/images'
   193                  }]
   194              }
   195          },
   196          svgmin: {
   197              dist: {
   198                  files: [{
   199                      expand: true,
   200                      cwd: '<%= yeoman.app %>/images',
   201                      src: '{,*/}*.svg',
   202                      dest: '<%= yeoman.dist %>/images'
   203                  }]
   204              }
   205          },
   206          cssmin: {
   207              // This task is pre-configured if you do not wish to use Usemin
   208              // blocks for your CSS. By default, the Usemin block from your
   209              // `index.html` will take care of minification, e.g.
   210              //
   211              //     <!-- build:css({.tmp,app}) styles/main.css -->
   212              //
   213              // dist: {
   214              //     files: {
   215              //         '<%= yeoman.dist %>/styles/main.css': [
   216              //             '.tmp/styles/{,*/}*.css',
   217              //             '<%= yeoman.app %>/styles/{,*/}*.css'
   218              //         ]
   219              //     }
   220              // }
   221          },
   222          htmlmin: {
   223              dist: {
   224                  options: {
   225                      /*removeCommentsFromCDATA: true,
   226                      // https://github.com/yeoman/grunt-usemin/issues/44
   227                      //collapseWhitespace: true,
   228                      collapseBooleanAttributes: true,
   229                      removeAttributeQuotes: true,
   230                      removeRedundantAttributes: true,
   231                      useShortDoctype: true,
   232                      removeEmptyAttributes: true,
   233                      removeOptionalTags: true*/
   234                  },
   235                  files: [{
   236                      expand: true,
   237                      cwd: '<%= yeoman.app %>',
   238                      src: '*.html',
   239                      dest: '<%= yeoman.dist %>'
   240                  }]
   241              }
   242          },
   243          // Put files not handled in other tasks here
   244          copy: {
   245              dist: {
   246                  files: [{
   247                      expand: true,
   248                      dot: true,
   249                      cwd: '<%= yeoman.app %>',
   250                      dest: '<%= yeoman.dist %>',
   251                      src: [
   252                          '*.{ico,png,txt}',
   253                          '.htaccess',
   254                          'images/{,*/}*.{webp,gif}',
   255                          'styles/fonts/{,*/}*.*',
   256                          'views/*.*',
   257                          'index.html',
   258                          'bower_components/sass-bootstrap/fonts/*.*'
   259                      ]
   260                  }]
   261              },
   262              styles: {
   263                  expand: true,
   264                  dot: true,
   265                  cwd: '<%= yeoman.app %>/styles',
   266                  dest: '.tmp/styles/',
   267                  src: '{,*/}*.css'
   268              }
   269          },
   270          modernizr: {
   271              devFile: '<%= yeoman.app %>/bower_components/modernizr/modernizr.js',
   272              outputFile: '<%= yeoman.dist %>/bower_components/modernizr/modernizr.js',
   273              files: [
   274                  '<%= yeoman.dist %>/scripts/{,*/}*.js',
   275                  '<%= yeoman.dist %>/styles/{,*/}*.css',
   276                  '!<%= yeoman.dist %>/scripts/vendor/*'
   277              ],
   278              uglify: true
   279          },
   280          concurrent: {
   281              server: [
   282                  'compass',
   283                  'copy:styles'
   284              ],
   285              test: [
   286                  'copy:styles'
   287              ],
   288              dist: [
   289                  'compass',
   290                  'copy:styles',
   291                  'imagemin',
   292                  'svgmin',
   293                  'htmlmin'
   294              ]
   295          },
   296          bower: {
   297              options: {
   298                  exclude: ['modernizr']
   299              },
   300              all: {
   301                  rjsConfig: '<%= yeoman.app %>/scripts/main.js'
   302              }
   303          }
   304      });
   305  
   306      grunt.registerTask('server', function (target) {
   307          if (target === 'dist') {
   308              return grunt.task.run(['build', 'connect:dist:keepalive']);
   309          }
   310  
   311          grunt.task.run([
   312              'clean:server',
   313              'concurrent:server',
   314              'autoprefixer',
   315              'connect:livereload',
   316              'watch'
   317          ]);
   318      });
   319  
   320      grunt.registerTask('test', [
   321          'clean:server',
   322          'concurrent:test',
   323          'autoprefixer',
   324          'connect:test',
   325          'mocha'
   326      ]);
   327  
   328      grunt.registerTask('build', [
   329          'clean:dist',
   330          'useminPrepare',
   331          'concurrent:dist',
   332          'autoprefixer',
   333          'concat',
   334          'cssmin',
   335          'uglify',
   336          'usemin',
   337          'copy:dist'
   338      ]);
   339  
   340      grunt.registerTask('default', [
   341          'jshint',
   342          'test',
   343          'build'
   344      ]);
   345  };