/** * Created by robin on 11/10/15. */ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-istanbul-coverage'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-html-build'); grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-ngdocs'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-filerev'); grunt.loadNpmTasks('grunt-usemin'); grunt.loadNpmTasks('grunt-rebase'); var path = require('path'); grunt.initConfig({ globals: { releasePath: 'build/release', appFolder: '.', staticFiles: [ 'views/**/*.html', 'index.html', 'favicon.ico', 'img/**', 'fonts/**', 'css/**' ] }, useminPrepare: { release: '<%= globals.appFolder %>/index.html', options: { flow: { release: { steps: { 'js': [ { name: 'coverage', createConfig: function (context, block) { var cfg = {files: []}; context.options.options = { thresholds: { 'statements': 90, 'branches': 90, 'lines': 90, 'functions': 90 }, dir: 'coverage/<%= globals.appFolder %>', root: 'test' }; context.outFiles = context.inFiles; context.outDir = context.inDir; return cfg; } }, 'concat', { name: 'uglify', createConfig: function (context, block) { var cfg = {files: []}, outfile = path.join('<%= globals.releasePath %>', block.dest), filesDef = {}; filesDef.dest = outfile; filesDef.src = []; context.inFiles.forEach(function (inFile) { filesDef.src.push(path.join(context.inDir, inFile)); }); cfg.files.push(filesDef); //context.outFiles = [block.dest]; return cfg; } } ], 'css': ['concat', { name: 'cssmin', createConfig: function (context, block) { var cfg = {files: []}, outfile = path.join('<%= globals.releasePath %>', block.dest), filesDef = {}; filesDef.dest = outfile; filesDef.src = []; context.inFiles.forEach(function (inFile) { filesDef.src.push(path.join(context.inDir, inFile)); }); cfg.files.push(filesDef); //context.outFiles = [block.dest]; return cfg; } }], 'less': [ { name: 'less', createConfig: function (context, block) { var cfg = {files: []}, outfile = path.join('<%= globals.releasePath %>', block.dest), filesDef = {}; context.options.generated.options = { cleancss: true }; filesDef.dest = outfile; filesDef.src = []; context.inFiles.forEach(function (inFile) { filesDef.src.push(path.join(context.inDir, inFile)); }); cfg.files.push(filesDef); return cfg; } } ] }, post: { } }, } } }, usemin: { html: '<%= globals.releasePath %>/index.html', options: { blockReplacements: { less: function (block) { return ''; } } } }, copy: { release: { files: [ { expand:true, cwd:'<%= globals.appFolder %>/', src: ['<%= globals.staticFiles %>'], dest: '<%= globals.releasePath %>' }, { expand: true, cwd:'<%= globals.appFolder %>/bower_components/flat-ui/dist/fonts/', src: ['**'], dest: '<%= globals.releasePath %>/fonts/' } ] } }, clean: { release: ['<%= globals.releasePath %>/*'] } }); grunt.registerTask('release', [ 'clean:release', 'useminPrepare:release', 'concat:generated', 'uglify:generated', 'copy:release', 'cssmin:generated', // 'less:generated', 'usemin' ]); };