build_task.js 1.7 KB

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