build_task.js 1.3 KB

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