build_task.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. 'karma:test',
  9. 'clean:on_start',
  10. 'less:src',
  11. 'concat:cssDark',
  12. 'concat:cssLight',
  13. 'copy:everything_but_less_to_temp',
  14. 'htmlmin:build',
  15. 'ngtemplates',
  16. 'cssmin:build',
  17. 'ngAnnotate:build',
  18. 'requirejs:build',
  19. 'concat:js',
  20. 'filerev',
  21. 'remapFilerev',
  22. 'usemin',
  23. 'clean:temp',
  24. 'uglify:dest'
  25. ]);
  26. // task to add [[.AppSubUrl]] to reved path
  27. grunt.registerTask('remapFilerev', function(){
  28. var root = grunt.config().destDir;
  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]]');
  34. var revved = summary[key].replace(root, root+'/[[.AppSubUrl]]');
  35. fixed[orig] = revved;
  36. }
  37. }
  38. grunt.filerev.summary = fixed;
  39. });
  40. grunt.registerTask('build-post-process', function() {
  41. grunt.config('copy.dist_to_tmp', {
  42. expand: true,
  43. cwd: '<%= destDir %>',
  44. src: '**/*',
  45. dest: '<%= tempDir %>/public/',
  46. });
  47. grunt.config('clean.dest_dir', ['<%= destDir %>']);
  48. grunt.config('copy.backend_bin', {
  49. cwd: 'bin',
  50. expand: true,
  51. src: ['grafana'],
  52. options: { mode: true},
  53. dest: '<%= tempDir %>'
  54. });
  55. grunt.config('copy.backend_files', {
  56. expand: true,
  57. src: ['conf/defaults.ini', 'conf/sample.ini', 'vendor/**/*', 'scripts/*'],
  58. options: { mode: true},
  59. dest: '<%= tempDir %>'
  60. });
  61. grunt.task.run('copy:dist_to_tmp');
  62. grunt.task.run('clean:dest_dir');
  63. grunt.task.run('copy:backend_bin');
  64. grunt.task.run('copy:backend_files');
  65. });
  66. };