build_task.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. 'requirejs:build',
  20. 'concat:js',
  21. 'clean:temp',
  22. 'filerev',
  23. 'remapFilerev',
  24. 'usemin',
  25. 'clean:temp',
  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]]');
  36. var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]');
  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/defaults.ini', 'conf/sample.ini', 'vendor/**/*', '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. });
  66. };