build_task.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. 'clean:on_start',
  7. 'less:src',
  8. 'concat:css',
  9. 'copy:everything_but_less_to_temp',
  10. 'htmlmin:build',
  11. 'ngtemplates:app',
  12. 'cssmin:build',
  13. 'ngmin:build',
  14. 'requirejs:build',
  15. 'filerev',
  16. 'clean:temp',
  17. 'build:write_revision',
  18. 'uglify:dest'
  19. ]);
  20. // run a string replacement on the require config, using the latest revision number as the cache buster
  21. grunt.registerTask('build:write_revision', function() {
  22. grunt.event.once('git-describe', function (desc) {
  23. grunt.config('string-replace.config', {
  24. files: {
  25. '<%= destDir %>/app/components/require.config.js': '<%= destDir %>/app/components/require.config.js',
  26. '<%= destDir %>/app/app.js': '<%= destDir %>/app/app.js'
  27. },
  28. options: {
  29. replacements: [
  30. {
  31. pattern: /@REV@/g,
  32. replacement: desc.object
  33. },
  34. {
  35. pattern: /@grafanaVersion@/g,
  36. replacement: '<%= pkg.version %>'
  37. }
  38. ]
  39. }
  40. });
  41. grunt.task.run('string-replace:config');
  42. });
  43. grunt.task.run('git-describe');
  44. });
  45. };