您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Gruntfile.js 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * Created by robin on 11/10/15.
  3. */
  4. module.exports = function(grunt) {
  5. grunt.loadNpmTasks('grunt-contrib-jshint');
  6. grunt.loadNpmTasks('grunt-contrib-uglify');
  7. grunt.loadNpmTasks('grunt-contrib-copy');
  8. grunt.loadNpmTasks('grunt-istanbul-coverage');
  9. grunt.loadNpmTasks('grunt-contrib-clean');
  10. grunt.loadNpmTasks('grunt-html-build');
  11. grunt.loadNpmTasks('grunt-contrib-less');
  12. grunt.loadNpmTasks('grunt-ngdocs');
  13. grunt.loadNpmTasks('grunt-contrib-concat');
  14. grunt.loadNpmTasks('grunt-contrib-cssmin');
  15. grunt.loadNpmTasks('grunt-filerev');
  16. grunt.loadNpmTasks('grunt-usemin');
  17. grunt.loadNpmTasks('grunt-rebase');
  18. var path = require('path');
  19. grunt.initConfig({
  20. globals: {
  21. releasePath: 'build/release',
  22. appFolder: '.',
  23. staticFiles: [
  24. 'views/**/*.html',
  25. 'index.html',
  26. 'favicon.ico',
  27. 'img/**',
  28. 'fonts/**',
  29. 'css/**'
  30. ]
  31. },
  32. useminPrepare: {
  33. release: '<%= globals.appFolder %>/index.html',
  34. options: {
  35. flow: {
  36. release: {
  37. steps: {
  38. 'js': [
  39. {
  40. name: 'coverage',
  41. createConfig: function (context, block) {
  42. var cfg = {files: []};
  43. context.options.options = {
  44. thresholds: {
  45. 'statements': 90,
  46. 'branches': 90,
  47. 'lines': 90,
  48. 'functions': 90
  49. },
  50. dir: 'coverage/<%= globals.appFolder %>',
  51. root: 'test'
  52. };
  53. context.outFiles = context.inFiles;
  54. context.outDir = context.inDir;
  55. return cfg;
  56. }
  57. },
  58. 'concat',
  59. {
  60. name: 'uglify',
  61. createConfig: function (context, block) {
  62. var cfg = {files: []},
  63. outfile = path.join('<%= globals.releasePath %>', block.dest),
  64. filesDef = {};
  65. filesDef.dest = outfile;
  66. filesDef.src = [];
  67. context.inFiles.forEach(function (inFile) {
  68. filesDef.src.push(path.join(context.inDir, inFile));
  69. });
  70. cfg.files.push(filesDef);
  71. //context.outFiles = [block.dest];
  72. return cfg;
  73. }
  74. }
  75. ],
  76. 'css': ['concat',
  77. {
  78. name: 'cssmin',
  79. createConfig: function (context, block) {
  80. var cfg = {files: []},
  81. outfile = path.join('<%= globals.releasePath %>', block.dest),
  82. filesDef = {};
  83. filesDef.dest = outfile;
  84. filesDef.src = [];
  85. context.inFiles.forEach(function (inFile) {
  86. filesDef.src.push(path.join(context.inDir, inFile));
  87. });
  88. cfg.files.push(filesDef);
  89. //context.outFiles = [block.dest];
  90. return cfg;
  91. }
  92. }],
  93. 'less': [
  94. {
  95. name: 'less',
  96. createConfig: function (context, block) {
  97. var cfg = {files: []},
  98. outfile = path.join('<%= globals.releasePath %>', block.dest),
  99. filesDef = {};
  100. context.options.generated.options = {
  101. cleancss: true
  102. };
  103. filesDef.dest = outfile;
  104. filesDef.src = [];
  105. context.inFiles.forEach(function (inFile) {
  106. filesDef.src.push(path.join(context.inDir, inFile));
  107. });
  108. cfg.files.push(filesDef);
  109. return cfg;
  110. }
  111. }
  112. ]
  113. },
  114. post: {
  115. }
  116. },
  117. }
  118. }
  119. },
  120. usemin: {
  121. html: '<%= globals.releasePath %>/index.html',
  122. options: {
  123. blockReplacements: {
  124. less: function (block) {
  125. return '<link rel=\"stylesheet\" href=\"' + block.dest + '\"/>';
  126. }
  127. }
  128. }
  129. },
  130. copy: {
  131. release: {
  132. files: [
  133. {
  134. expand:true,
  135. cwd:'<%= globals.appFolder %>/',
  136. src: ['<%= globals.staticFiles %>'],
  137. dest: '<%= globals.releasePath %>'
  138. },
  139. {
  140. expand: true,
  141. cwd:'<%= globals.appFolder %>/bower_components/flat-ui/dist/fonts/',
  142. src: ['**'],
  143. dest: '<%= globals.releasePath %>/fonts/'
  144. }
  145. ]
  146. }
  147. },
  148. clean: {
  149. release: ['<%= globals.releasePath %>/*']
  150. }
  151. });
  152. grunt.registerTask('release', [
  153. 'clean:release',
  154. 'useminPrepare:release',
  155. 'concat:generated',
  156. 'uglify:generated',
  157. 'copy:release',
  158. 'cssmin:generated',
  159. // 'less:generated',
  160. 'usemin'
  161. ]);
  162. };