build_task.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. 'karma:test',
  8. 'clean:on_start',
  9. 'less:src',
  10. 'concat:cssDark',
  11. 'concat:cssLight',
  12. 'copy:everything_but_less_to_temp',
  13. 'htmlmin:build',
  14. 'ngtemplates',
  15. 'cssmin:build',
  16. 'build:grafanaVersion',
  17. 'ngAnnotate:build',
  18. 'requirejs:build',
  19. 'concat:js',
  20. 'filerev',
  21. 'usemin',
  22. 'clean:temp',
  23. //'uglify:dest'
  24. ]);
  25. grunt.registerTask('build-post-process', function() {
  26. var mode = grunt.config.get('mode');
  27. if (mode === 'backend') {
  28. grunt.config('copy.dist_to_tmp', {
  29. expand: true,
  30. cwd: '<%= destDir %>',
  31. src: '**/*',
  32. dest: '<%= tempDir %>/public/',
  33. });
  34. grunt.config('clean.dest_dir', ['<%= destDir %>']);
  35. grunt.config('copy.backend_bin', {
  36. cwd: 'bin',
  37. expand: true,
  38. src: ['grafana'],
  39. options: { mode: true},
  40. dest: '<%= tempDir %>'
  41. });
  42. grunt.config('copy.backend_files', {
  43. expand: true,
  44. src: ['conf/grafana.ini', 'vendor/**/*', 'scripts/*'],
  45. options: { mode: true},
  46. dest: '<%= tempDir %>'
  47. });
  48. grunt.task.run('copy:dist_to_tmp');
  49. grunt.task.run('clean:dest_dir');
  50. grunt.task.run('copy:backend_bin');
  51. grunt.task.run('copy:backend_files');
  52. }
  53. });
  54. grunt.registerTask('build:grafanaVersion', function() {
  55. grunt.config('string-replace.config', {
  56. files: {
  57. '<%= tempDir %>/app/app.js': '<%= tempDir %>/app/app.js'
  58. },
  59. options: {
  60. replacements: [{ pattern: /@grafanaVersion@/g, replacement: '<%= pkg.version %>' }]
  61. }
  62. });
  63. grunt.task.run('string-replace:config');
  64. });
  65. };