Guest User

Untitled

a guest
Mar 31st, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*global module:false*/
  2. module.exports = function(grunt) {
  3.  
  4.     // Project configuration.
  5.     grunt.initConfig({
  6.         // Metadata.
  7.         pkg: grunt.file.readJSON('package.json'),
  8.  
  9.         // Task configuration.
  10.         uglify: {
  11.             options: {
  12.                 banner: '<%= banner %>'
  13.             },
  14.             dist: {
  15.                 src: 'app/application.js',
  16.                 dest: 'dist/application.js'
  17.             }
  18.         },
  19.  
  20.         less: {
  21.             dev: {
  22.                 files: { 'app/css/styles.css': 'app/less/styles.less' },
  23.             },
  24.             prod: {
  25.                 files: { 'app/css/styles.css': 'app/less/styles.less' },
  26.                 options: { yuicompress: true }
  27.             }
  28.         },
  29.  
  30.         htmlmin: {
  31.             dist: {
  32.                 files: {'dist/index.html': 'app/index.html'},
  33.                 options: {
  34.                     removeComments: true,
  35.                     collapseWhitespace: true
  36.                 }
  37.             }
  38.         },
  39.  
  40.         imagemin: {
  41.             dist: {
  42.                 options: {
  43.                     optimizationLevel: 7,
  44.                     progressive: true
  45.                 },
  46.                 files: {
  47.                     'dist/imgs/': 'app/imgs/**',
  48.                     'dist/css/images/': 'app/css/jquery-ui/cupertino/images/**'
  49.                 }
  50.             }
  51.         },
  52.  
  53.         cssmin: {
  54.             dist: {
  55.                 files: {
  56.                     'dist/css/styles.css': [
  57.                         'app/css/jquery-ui/cupertino/jquery-ui.min.css',
  58.                         'app/css/styles.css'
  59.                     ]
  60.                 },
  61.                 options: {
  62.                     keepSpecialComments: 0,
  63.                     report: 'min'
  64.                 }
  65.             }
  66.         },
  67.  
  68.         clean: ['dist'],
  69.  
  70.         jasmine: {
  71.             test: {
  72.                 src: 'app/application.js',
  73.                 options: {
  74.                     specs: 'app/tests/*.js',
  75.                     styles: 'css/styles.css'
  76.                 }
  77.             }
  78.         },
  79.  
  80.         watch: {
  81.             js: {
  82.                 files: [
  83.                     'app/controllers/**',
  84.                     'app/less/**',
  85.                     'app/extras/**',
  86.                     'app/less/**',
  87.                     'app/models/**',
  88.                     'app/routes/**',
  89.                     'app/templates/**',
  90.                     'app/vendor/**',
  91.                     'app/views/**',
  92.                     'routes.js',
  93.                     'store.js',
  94.                     'app.js'
  95.                 ],
  96.                 tasks: ['build']
  97.             },
  98.             less: {
  99.                 files: ['app/less/*'],
  100.                 tasks: ['less:dev']
  101.             }
  102.         }
  103.     });
  104.  
  105.     // These plugins provide necessary tasks.
  106.     (function() {
  107.         grunt.loadNpmTasks('grunt-contrib-concat');
  108.         grunt.loadNpmTasks('grunt-contrib-uglify');
  109.         grunt.loadNpmTasks('grunt-contrib-htmlmin');
  110.         grunt.loadNpmTasks('grunt-contrib-imagemin');
  111.         grunt.loadNpmTasks('grunt-contrib-cssmin');
  112.         grunt.loadNpmTasks('grunt-contrib-less');
  113.         grunt.loadNpmTasks('grunt-contrib-jasmine');
  114.         grunt.loadNpmTasks('grunt-contrib-clean');
  115.         grunt.loadNpmTasks('grunt-contrib-watch');
  116.     })()
  117.  
  118.     grunt.registerTask('build', 'Runs ember-tools build command', function() {
  119.         var done = this.async();
  120.         grunt.util.spawn({ cmd: 'ember', args: ['build'] }, function(e, result) {
  121.             grunt.log.writeln(result);
  122.             done();
  123.         });
  124.     });
  125.  
  126.     grunt.registerTask('prepare-dist', 'Creates folders needed for distribution', function() {
  127.         var folders = ['dist/css/images', 'dist/imgs'];
  128.         for (var i in folders) {
  129.             var done = this.async();
  130.             grunt.util.spawn({ cmd: 'mkdir', args: ['-p', folders[i]] }, function(e, result) {
  131.                 grunt.log.writeln('Folder created');
  132.                 done();
  133.             });
  134.         }
  135.     });
  136.  
  137.     grunt.registerTask('default', ['dist']);
  138.  
  139.     grunt.registerTask('dist', [
  140.         'clean',
  141.         'prepare-dist',
  142.         'build',
  143.         'compress',
  144.         'jasmine'
  145.     ]);
  146.  
  147.     grunt.registerTask('compress', [
  148.         'less:prod',
  149.         'htmlmin',
  150.         'imagemin',
  151.         'cssmin',
  152.         'uglify'
  153.     ]);
  154.  
  155.     grunt.registerTask('css', ['less:dev']);
  156.  
  157.     grunt.registerTask('css-prod', ['less:prod']);
  158.  
  159. };
Advertisement
Add Comment
Please, Sign In to add comment