build_task.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. module.exports = function(grunt) {
  2. // Concat and Minify the src directory into dist
  3. grunt.registerTask('build', [
  4. 'jshint:source',
  5. 'jshint:tests',
  6. 'karma:test',
  7. 'clean:on_start',
  8. 'less:src',
  9. 'concat:cssDark',
  10. 'concat:cssLight',
  11. 'copy:everything_but_less_to_temp',
  12. 'htmlmin:build',
  13. 'ngtemplates',
  14. 'cssmin:build',
  15. 'build:grafanaVersion',
  16. 'ngmin:build',
  17. 'requirejs:build',
  18. 'concat:js',
  19. 'filerev',
  20. 'usemin',
  21. 'clean:temp',
  22. //'uglify:dest'
  23. ]);
  24. grunt.registerTask('build-post-process', function() {
  25. var mode = grunt.config.get('mode');
  26. if (mode === 'backend') {
  27. grunt.config('copy.dist_to_tmp', {
  28. expand: true,
  29. cwd: '<%= destDir %>',
  30. src: '**/*',
  31. dest: '<%= tempDir %>/public/',
  32. });
  33. grunt.config('copy.backend_bin', {
  34. cwd: '../bin',
  35. expand: true,
  36. src: ['grafana'],
  37. options: { mode: true},
  38. dest: '<%= tempDir %>'
  39. });
  40. grunt.config('copy.backend_conf', {
  41. cwd: '../',
  42. expand: true,
  43. src: ['conf/*', '!conf/grafana.dev.ini'],
  44. dest: '<%= tempDir %>'
  45. });
  46. grunt.task.run('copy:dist_to_tmp');
  47. grunt.task.run('copy:backend_bin');
  48. grunt.task.run('copy:backend_conf');
  49. }
  50. });
  51. grunt.registerTask('build:grafanaVersion', function() {
  52. grunt.config('string-replace.config', {
  53. files: {
  54. '<%= tempDir %>/app/app.js': '<%= tempDir %>/app/app.js'
  55. },
  56. options: {
  57. replacements: [{ pattern: /@grafanaVersion@/g, replacement: '<%= pkg.version %>' }]
  58. }
  59. });
  60. grunt.task.run('string-replace:config');
  61. });
  62. };