Gruntfile.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. module.exports = function(grunt) {
  2. //初始化配置grunt任务
  3. grunt.initConfig({
  4. concat: {//任务名称
  5. curing: {
  6. src: ['global/js/cloud/curing.js','global/js/cloud/curingFN.js','global/js/cloud/curingHtml.js'],
  7. dest: 'global/js/cloud/curing.concat.js'
  8. },
  9. build:{
  10. src: ['global/js/cloud/build.js','global/js/cloud/buildFN.js','global/js/cloud/buildHtml.js'],
  11. dest: 'global/js/cloud/build.concat.js'
  12. },
  13. },
  14. pkg: grunt.file.readJSON('package.json'),
  15. uglify: {
  16. options: {
  17. banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'//添加banner
  18. },
  19. curing: {//任务一:压缩a.js,不混淆变量名,保留注释,添加banner和footer
  20. options: {
  21. mangle: true, //false 不混淆变量名
  22. preserveComments: 'false', //不删除注释,还可以为 false(删除全部注释),some(保留@preserve @license @cc_on等注释)
  23. footer:'\n/*! <%= pkg.name %> 最后修改于: <%= grunt.template.today("yyyy-mm-dd") %> */'//添加footer
  24. },
  25. files: {
  26. 'global/js/cloud/curing.min.js': ['global/js/cloud/curing.concat.js']
  27. }
  28. },
  29. build: {
  30. options: {
  31. mangle: true,
  32. preserveComments: 'false',
  33. footer:'\n/*! <%= pkg.name %> 最后修改于: <%= grunt.template.today("yyyy-mm-dd") %> */'
  34. },
  35. files: {
  36. 'global/js/cloud/build.min.js': ['global/js/cloud/build.concat.js']
  37. }
  38. },
  39. // build:{//任务二:压缩b.js,输出压缩信息
  40. // options: {
  41. // report: "min"//输出压缩率,可选的值有 false(不输出信息),gzip
  42. // },
  43. // files: {
  44. // 'output/js/b.min.js': ['js/main/b.js']
  45. // }
  46. // },
  47. // buildall: {//任务三:按原文件结构压缩js文件夹内所有JS文件
  48. // files: [{
  49. // expand:true,
  50. // cwd:'js',//js目录下
  51. // src:'**/*.js',//所有js文件
  52. // dest: 'output/js'//输出到此目录下
  53. // }]
  54. // },
  55. // release: {//任务四:合并压缩a.js和b.js
  56. // files: {
  57. // 'output/js/index.min.js': ['js/a.js', 'js/main/b.js']
  58. // }
  59. // }
  60. },
  61. jshint:{
  62. options:{
  63. jshintrc:'.jshintrc'
  64. },
  65. build:['global/js/cloud/*.js']
  66. }
  67. });
  68. grunt.loadNpmTasks('grunt-contrib-concat');
  69. grunt.loadNpmTasks('grunt-contrib-uglify');
  70. grunt.loadNpmTasks('grunt-contrib-jshint');
  71. //注册grunt默认任务
  72. grunt.registerTask('default', ['concat','uglify','jshint']);
  73. };