Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Gruntfile_02_app.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * Created by robin on 11/10/15.
  3. */
  4. module.exports = function(grunt) {
  5. grunt.loadNpmTasks('grunt-contrib-clean');
  6. grunt.loadNpmTasks('grunt-usemin');
  7. grunt.loadNpmTasks('grunt-contrib-concat');
  8. grunt.loadNpmTasks('grunt-contrib-uglify');
  9. grunt.loadNpmTasks('grunt-contrib-copy');
  10. grunt.loadNpmTasks('grunt-contrib-cssmin');
  11. grunt.loadNpmTasks('grunt-contrib-less');
  12. var path = require('path');
  13. grunt.initConfig({
  14. globals: {
  15. releasePath: 'build/release/app',
  16. appFolder: 'app',
  17. staticFiles: [
  18. 'views/**/*.html',
  19. 'index.html',
  20. 'img/**',
  21. 'fonts/**',
  22. 'translations/**'
  23. ]
  24. },
  25. useminPrepare: {
  26. release: '<%= globals.appFolder %>/index.html',
  27. options: {
  28. flow: {
  29. release: {
  30. steps: {
  31. 'js': [
  32. 'concat',
  33. {
  34. name: 'uglify',
  35. createConfig: function (context, block) {
  36. var cfg = {files: []},
  37. filesDef = {};
  38. filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
  39. filesDef.src = [];
  40. context.inFiles.forEach(function (inFile) {
  41. filesDef.src.push(path.join(context.inDir, inFile));
  42. });
  43. cfg.files.push(filesDef);
  44. return cfg;
  45. }
  46. }
  47. ],
  48. 'css': ['concat',
  49. {
  50. name: 'cssmin',
  51. createConfig: function (context, block) {
  52. var cfg = {files: []},
  53. filesDef = {};
  54. filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
  55. filesDef.src = [];
  56. context.inFiles.forEach(function (inFile) {
  57. filesDef.src.push(path.join(context.inDir, inFile));
  58. });
  59. cfg.files.push(filesDef);
  60. return cfg;
  61. }
  62. }],
  63. 'less': [
  64. {
  65. name: 'less',
  66. createConfig: function (context, block) {
  67. var cfg = {files: []},
  68. filesDef = {};
  69. context.options.generated.options = {
  70. cleancss: true
  71. };
  72. filesDef.dest = path.join('<%= globals.releasePath %>', block.dest);
  73. filesDef.src = [];
  74. context.inFiles.forEach(function (inFile) {
  75. filesDef.src.push(path.join(context.inDir, inFile));
  76. });
  77. cfg.files.push(filesDef);
  78. return cfg;
  79. }
  80. }
  81. ]
  82. },
  83. post: {
  84. }
  85. }
  86. }
  87. }
  88. },
  89. usemin: {
  90. html: '<%= globals.releasePath %>/index.html',
  91. options: {
  92. blockReplacements: {
  93. less: function (block) {
  94. return '<link rel=\"stylesheet\" href=\"' + block.dest + '\"/>';
  95. }
  96. }
  97. }
  98. },
  99. copy: {
  100. release: {
  101. files: [
  102. {
  103. expand: true,
  104. cwd:'<%= globals.appFolder %>/',
  105. src: ['<%= globals.staticFiles %>'],
  106. dest: '<%= globals.releasePath %>'
  107. },
  108. {
  109. expand: true,
  110. cwd:'<%= globals.appFolder %>/../bower_components/components-font-awesome/fonts/',
  111. src: ['**'],
  112. dest: '<%= globals.releasePath %>/fonts/'
  113. }
  114. ]
  115. }
  116. },
  117. clean: {
  118. release: ['<%= globals.releasePath %>/*']
  119. }
  120. });
  121. grunt.registerTask('default', [
  122. 'clean:release',
  123. 'useminPrepare:release',
  124. 'concat:generated',
  125. 'uglify:generated',
  126. 'copy:release',
  127. 'cssmin:generated',
  128. 'less:generated',
  129. 'usemin'
  130. ]);
  131. };