Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. var src = "src";
  2. var build = "build";
  3. module.exports = function(grunt) {
  4. grunt.initConfig({
  5. babel: {
  6. options: {
  7. experimental: true,
  8. compact: false,
  9. comments: true
  10. },
  11. scripts: {
  12. options: {},
  13. files: [{
  14. expand: true,
  15. cwd: src,
  16. dest: build,
  17. src: ["**/*.js"]
  18. }]
  19. }
  20. },
  21. concat: {
  22. },
  23. uglify: {
  24. minify: {
  25. options: {
  26. beautify: false,
  27. compress: {
  28. sequences: true,
  29. properties: true,
  30. dead_code: true,
  31. drop_debugger: true,
  32. conditionals: true,
  33. comparisons: true,
  34. evaluate: true,
  35. booleans: true,
  36. loops: true,
  37. unused: true,
  38. hoist_funs: true,
  39. if_return: true,
  40. join_vars: true,
  41. cascade: true,
  42. negate_iife: true
  43. },
  44. mangle: true
  45. },
  46. files: [{
  47. expand: true,
  48. cwd: build,
  49. dest: build,
  50. ext: ".min.js",
  51. extDot: "last",
  52. src: ["**/*.js", "!**/*.min.js"]
  53. }]
  54. },
  55. beautify: {
  56. options: {
  57. beautify: {
  58. beautify: true,
  59. width: 200,
  60. space_colon: false
  61. },
  62. compress: false,
  63. screw_ie8: true,
  64. mangle: false
  65. },
  66. files: [{
  67. expand: true,
  68. cwd: build,
  69. dest: build,
  70. src: ["**/*.js", "!**/*.min.js"]
  71. }]
  72. }
  73. },
  74. less: {
  75. compile: {
  76. options: {
  77. ieCompat: false
  78. },
  79. files: [{
  80. expand: true,
  81. cwd: src,
  82. dest: build,
  83. ext: ".css",
  84. extDot: "last",
  85. src: ["**/*.less", "!**/*.import.less"]
  86. }]
  87. }
  88. },
  89. cssmin: {
  90. minify: {
  91. files: [{
  92. expand: true,
  93. cwd: build,
  94. dest: build,
  95. ext: ".min.css",
  96. extDot: "last",
  97. src: ["**/*.css", "!**/*.min.css"]
  98. }]
  99. }
  100. },
  101. htmlmin: {
  102. minify: {
  103. options: {
  104. removeComments: true,
  105. useShortDoctype: true,
  106. customAttrAssign: [/\?=/g, /\$=/g],
  107. minifyJS: true,
  108. minifyCSS: true,
  109. collapseWhitespace: true
  110. },
  111. files: [{
  112. expand: true,
  113. cwd: build,
  114. dest: build,
  115. ext: ".min.html",
  116. extDot: "last",
  117. src: ["**/*.html", "!**/*.min.html"]
  118. }]
  119. }
  120. },
  121. vulcanize: {
  122. elements: {
  123. options: {
  124. inlineScripts: true,
  125. inlineCss: true
  126. },
  127. files: {
  128. "build/vulcanized.html": "build/elements.html"
  129. }
  130. }
  131. },
  132. copy: {
  133. appcache: {
  134. files: [{
  135. expand: true,
  136. cwd: src,
  137. dest: build,
  138. src: ["**/*.appcache"]
  139. }]
  140. },
  141. html: {
  142. files: [{
  143. expand: true,
  144. cwd: src,
  145. dest: build,
  146. src: ["**/*.html"]
  147. }]
  148. }
  149. },
  150. watch: {
  151. options: {
  152. atBegin: true
  153. },
  154. transpileScripts: {
  155. files: [src + "/**/*.js"],
  156. tasks: ["babel"]
  157. },
  158. /*concatAsync: {
  159. files: [src + "/../scripts/*.js"],
  160. tasks: ["concat:async"]
  161. },*/
  162. minifyScripts: {
  163. files: [build + "/**/*.js", "!" + build + "/**/*.min.js"],
  164. tasks: ["uglify:minify"]
  165. },
  166. beautifyScripts: {
  167. files: [build + "/**/*.js", "!" + build + "/**/*.min.js"],
  168. tasks: ["uglify:beautify"]
  169. },
  170. compileLESS: {
  171. files: [src + "/**/*.less", "!" + src + "/**/*.import.less"],
  172. tasks: ["less:compile"]
  173. },
  174. minifyCSS: {
  175. files: [build + "/**/*.css", "!" + build + "/**/*.min.css"],
  176. tasks: ["cssmin:minify"]
  177. },
  178. copyHTML: {
  179. files: [src + "/**/*.html"],
  180. tasks: ["copy"]
  181. },
  182. minifyHTML: {
  183. files: [build + "/**/*.html"],
  184. tasks: ["htmlmin:minify"]
  185. },
  186. /*vulcanizePolymer: {
  187. files: ["src/*"],
  188. tasks: ["vulcanize:elements"]
  189. },*/
  190. copyAppcache: {
  191. files: [src + "/**/*.appcache"],
  192. tasks: ["copy"]
  193. },
  194. }
  195. });
  196. grunt.loadNpmTasks("grunt-contrib-concat");
  197. grunt.loadNpmTasks("grunt-babel");
  198. grunt.loadNpmTasks("grunt-contrib-uglify");
  199. grunt.loadNpmTasks("grunt-contrib-less");
  200. grunt.loadNpmTasks("grunt-contrib-cssmin");
  201. grunt.loadNpmTasks("grunt-vulcanize");
  202. grunt.loadNpmTasks("grunt-contrib-htmlmin");
  203. grunt.loadNpmTasks('grunt-contrib-copy');
  204. grunt.loadNpmTasks("grunt-contrib-watch");
  205. grunt.registerTask("default", ["watch"]);
  206. grunt.registerTask("run", ["copy", "babel", "concat", "uglify", "less", "cssmin", /*"vulcanize",*/ "htmlmin"]);
  207. };
  208. /*
  209. var package = {
  210. "dependencies": {
  211. "grunt": "",
  212. "grunt-cli": "",
  213. "grunt-contrib-copy": "",
  214. "grunt-contrib-cssmin": "",
  215. "grunt-contrib-htmlmin": "",
  216. "grunt-contrib-less": "",
  217. "grunt-contrib-uglify": "",
  218. "grunt-contrib-watch": "",
  219. "grunt-contrib-concat": "",
  220. "grunt-vulcanize": "",
  221. "grunt-babel": ""
  222. }
  223. };
  224. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement