build_task.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. module.exports = function(grunt) {
  2. // Concat and Minify the src directory into dist
  3. grunt.registerTask('build', [
  4. 'jshint:source',
  5. 'clean:on_start',
  6. 'less:dist',
  7. 'copy:everything_but_less_to_temp',
  8. 'htmlmin:build',
  9. 'cssmin:build',
  10. 'ngmin:build',
  11. 'requirejs:build',
  12. 'clean:temp',
  13. 'build:write_revision',
  14. 'uglify:dest'
  15. ]);
  16. // run a string replacement on the require config, using the latest revision number as the cache buster
  17. grunt.registerTask('build:write_revision', function() {
  18. grunt.event.once('git-describe', function (desc) {
  19. grunt.config('string-replace.config', {
  20. files: {
  21. '<%= destDir %>/app/components/require.config.js': '<%= destDir %>/app/components/require.config.js',
  22. '<%= destDir %>/app/app.js': '<%= destDir %>/app/app.js'
  23. },
  24. options: {
  25. replacements: [
  26. {
  27. pattern: /(?:^|\/\/)(.*)@REV@/,
  28. replacement: '$1'+desc.object
  29. },
  30. {
  31. pattern: /@REV@/,
  32. replacement: desc.object
  33. }
  34. ]
  35. }
  36. });
  37. grunt.task.run('string-replace:config');
  38. });
  39. grunt.task.run('git-describe');
  40. });
  41. };