电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.2 KiB

  1. /* Licensed under the Apache License, Version 2.0 (the "License");
  2. * you may not use this file except in compliance with the License.
  3. * You may obtain a copy of the License at
  4. *
  5. * http://www.apache.org/licenses/LICENSE-2.0
  6. *
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. 'use strict';
  14. module.exports = function (grunt) {
  15. require('load-grunt-tasks')(grunt);
  16. require('time-grunt')(grunt);
  17. grunt.initConfig({
  18. yeoman: {
  19. app: require('./package.json').appPath || 'app',
  20. dist: 'dist'
  21. },
  22. clean: {
  23. dist: {
  24. files: [
  25. {
  26. dot: true,
  27. src: [
  28. '.tmp',
  29. '<%= yeoman.dist %>/*',
  30. '!<%= yeoman.dist %>/.git*'
  31. ]
  32. }
  33. ]
  34. },
  35. server: '.tmp'
  36. },
  37. useminPrepare: {
  38. html: 'displaymodel.html',
  39. options: {
  40. dest: '<%= yeoman.dist %>/'
  41. }
  42. },
  43. usemin: {
  44. html: ['<%= yeoman.dist %>/{,*/}*.html'],
  45. css: ['<%= yeoman.dist %>/display/styles/{,*/}*.css'],
  46. options: {
  47. dirs: ['<%= yeoman.dist %>']
  48. }
  49. },
  50. // Put files not handled in other tasks here
  51. copy: {
  52. dist: {
  53. files: [{
  54. expand: true,
  55. dot: true,
  56. cwd: '.',
  57. dest: '<%= yeoman.dist %>',
  58. src: [
  59. 'fonts/*'
  60. ]
  61. }, {
  62. expand: true,
  63. cwd: '.tmp/images',
  64. dest: '<%= yeoman.dist %>/images',
  65. src: [
  66. 'generated/*'
  67. ]
  68. }]
  69. },
  70. styles: {
  71. expand: true,
  72. cwd: 'styles',
  73. dest: '.tmp/styles/',
  74. src: '{,*/}*.css'
  75. },
  76. index: {
  77. expand: true,
  78. cwd: './',
  79. src: ['*.html', 'views/**/**.html'],
  80. dest: '<%= yeoman.dist %>'
  81. },
  82. copyCss : {
  83. files: [
  84. {expand: true, cwd:'.tmp/concat/display/styles/', src:'*.css', dest:'<%= yeoman.dist %>/display/styles/', filter: 'isFile'}
  85. ]
  86. },
  87. copyJs : {
  88. files: [
  89. {expand: true, cwd:'.tmp/concat/display/scripts', src:'*.js', dest:'<%= yeoman.dist %>/display/scripts/', filter: 'isFile'}
  90. ]
  91. },
  92. },
  93. ngAnnotate: {
  94. dist: {
  95. files: [
  96. {
  97. expand: true,
  98. cwd: '.tmp/concat/display/scripts',
  99. src: '*.js',
  100. dest: '.tmp/concat/display/scripts'
  101. }
  102. ]
  103. }
  104. },
  105. uglify: {
  106. dist: {
  107. options: {
  108. mangle: true
  109. },
  110. files: {
  111. '<%= yeoman.dist %>/display/scripts/displaymodel-logic.js': [
  112. '<%= yeoman.dist %>/display/scripts/displaymodel-logic.js'
  113. ]
  114. }
  115. }
  116. },
  117. rev: {
  118. dist: {
  119. files: {
  120. src: [
  121. '<%= yeoman.dist %>/display/{,*/}*.js',
  122. '<%= yeoman.dist %>/display/{,*/}*.css',
  123. '<%= yeoman.dist %>/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
  124. ]
  125. }
  126. }
  127. }
  128. });
  129. grunt.registerTask('buildApp', [
  130. 'clean:dist',
  131. 'useminPrepare',
  132. 'copy:styles',
  133. 'concat',
  134. 'copy:dist',
  135. 'ngAnnotate',
  136. 'copy:copyCss',
  137. 'copy:copyJs',
  138. 'copy:index',
  139. 'uglify',
  140. 'rev',
  141. 'usemin'
  142. ]);
  143. grunt.registerTask('default', [
  144. 'buildApp'
  145. ]);
  146. };