Gruntfile.js 3.4 KB

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