build_task.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var path = require('path');
  2. module.exports = function(grunt) {
  3. "use strict";
  4. // Concat and Minify the src directory into dist
  5. grunt.registerTask('build', [
  6. 'jshint:source',
  7. 'jshint:tests',
  8. 'jscs',
  9. 'exec:tslint',
  10. 'clean:release',
  11. 'copy:node_modules',
  12. 'copy:public_to_gen',
  13. 'exec:tscompile',
  14. 'karma:test',
  15. 'phantomjs',
  16. 'css',
  17. 'htmlmin:build',
  18. 'ngtemplates',
  19. 'cssmin:build',
  20. 'ngAnnotate:build',
  21. 'systemjs:build',
  22. 'concat:js',
  23. 'filerev',
  24. 'remapFilerev',
  25. 'usemin',
  26. 'uglify:genDir'
  27. ]);
  28. // task to add [[.AppSubUrl]] to reved path
  29. grunt.registerTask('remapFilerev', function() {
  30. var root = grunt.config().genDir;
  31. var summary = grunt.filerev.summary;
  32. var fixed = {};
  33. for(var key in summary){
  34. if(summary.hasOwnProperty(key)){
  35. var orig = key.replace(root, root+'/[[.AppSubUrl]]/public');
  36. var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]/public');
  37. fixed[orig] = revved;
  38. }
  39. }
  40. grunt.filerev.summary = fixed;
  41. });
  42. grunt.registerTask('build-post-process', function() {
  43. grunt.config('copy.public_gen_to_temp', {
  44. expand: true,
  45. cwd: '<%= genDir %>',
  46. src: '**/*',
  47. dest: '<%= tempDir %>/public/',
  48. });
  49. grunt.config('copy.backend_bin', {
  50. cwd: 'bin',
  51. expand: true,
  52. src: ['*'],
  53. options: { mode: true},
  54. dest: '<%= tempDir %>/bin/'
  55. });
  56. grunt.config('copy.backend_files', {
  57. expand: true,
  58. src: ['conf/*', 'vendor/phantomjs/*', 'scripts/*'],
  59. options: { mode: true},
  60. dest: '<%= tempDir %>'
  61. });
  62. grunt.task.run('copy:public_gen_to_temp');
  63. grunt.task.run('copy:backend_bin');
  64. grunt.task.run('copy:backend_files');
  65. grunt.file.write(path.join(grunt.config('tempDir'), 'VERSION'), grunt.config('pkg.version'));
  66. });
  67. };