build_task.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/*', 'vendor/**/*', '!conf/grafana.dev.ini'],
  45. dest: '<%= tempDir %>'
  46. });
  47. grunt.task.run('copy:dist_to_tmp');
  48. grunt.task.run('clean:dest_dir');
  49. grunt.task.run('copy:backend_bin');
  50. grunt.task.run('copy:backend_files');
  51. }
  52. });
  53. grunt.registerTask('build:grafanaVersion', function() {
  54. grunt.config('string-replace.config', {
  55. files: {
  56. '<%= tempDir %>/app/app.js': '<%= tempDir %>/app/app.js'
  57. },
  58. options: {
  59. replacements: [{ pattern: /@grafanaVersion@/g, replacement: '<%= pkg.version %>' }]
  60. }
  61. });
  62. grunt.task.run('string-replace:config');
  63. });
  64. };