123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- /**
- * 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 '<link rel=\"stylesheet\" href=\"' + block.dest + '\"/>';
- }
- }
- }
- },
- 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'
- ]);
-
-
- };
|