Gruntfile.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. module.exports = function(grunt) {
  2. var BANNER = '/* <%= pkg.name %> <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>), Copyright (C) kindsoft.net, Licence: http://kindeditor.net/license.php */\r\n';
  3. var SRC_FILES = [
  4. 'src/header.js',
  5. 'src/core.js',
  6. 'src/config.js',
  7. 'src/event.js',
  8. 'src/html.js',
  9. 'src/selector.js',
  10. 'src/node.js',
  11. 'src/range.js',
  12. 'src/cmd.js',
  13. 'src/widget.js',
  14. 'src/edit.js',
  15. 'src/toolbar.js',
  16. 'src/menu.js',
  17. 'src/colorpicker.js',
  18. 'src/uploadbutton.js',
  19. 'src/dialog.js',
  20. 'src/tabs.js',
  21. 'src/ajax.js',
  22. 'src/main.js',
  23. 'src/footer.js',
  24. ];
  25. var PLUGIN_FILES = [
  26. 'plugins/anchor/anchor.js',
  27. 'plugins/autoheight/autoheight.js',
  28. 'plugins/baidumap/baidumap.js',
  29. 'plugins/map/map.js',
  30. 'plugins/clearhtml/clearhtml.js',
  31. 'plugins/code/code.js',
  32. 'plugins/emoticons/emoticons.js',
  33. 'plugins/filemanager/filemanager.js',
  34. 'plugins/flash/flash.js',
  35. 'plugins/image/image.js',
  36. 'plugins/insertfile/insertfile.js',
  37. 'plugins/lineheight/lineheight.js',
  38. 'plugins/link/link.js',
  39. 'plugins/map/map.js',
  40. 'plugins/media/media.js',
  41. 'plugins/multiimage/multiimage.js',
  42. 'plugins/pagebreak/pagebreak.js',
  43. 'plugins/plainpaste/plainpaste.js',
  44. 'plugins/preview/preview.js',
  45. 'plugins/quickformat/quickformat.js',
  46. 'plugins/table/table.js',
  47. 'plugins/template/template.js',
  48. 'plugins/wordpaste/wordpaste.js',
  49. 'plugins/fixtoolbar/fixtoolbar.js'
  50. ];
  51. var pkg = grunt.file.readJSON('package.json');
  52. var lang = grunt.option('lang') || 'en';
  53. grunt.initConfig({
  54. pkg : pkg,
  55. concat : {
  56. options : {
  57. process : function(src, filepath) {
  58. src = src.replace(/\$\{VERSION\}/g, pkg.version + ' (' + grunt.template.today('yyyy-mm-dd') + ')');
  59. src = src.replace(/\$\{THISYEAR\}/g, grunt.template.today('yyyy'));
  60. src = src.replace(/\/\*\*(\r\n|\n)[\s\S]*?\*\//g, '');
  61. src = src.replace(/(^|\s)\/\/.*$/mg, '');
  62. src = src.replace(/(\r\n|\n)\/\*\*\/.*(\r\n|\n)/g, '');
  63. src = src.replace(/[ \t]+$/mg, '');
  64. src = src.replace(/(\r\n|\n){2,}/g, '$1');
  65. return src;
  66. }
  67. },
  68. build : {
  69. src : SRC_FILES.concat('lang/' + lang + '.js').concat(PLUGIN_FILES),
  70. dest : 'kindeditor-all.js'
  71. }
  72. },
  73. uglify : {
  74. options : {
  75. banner : BANNER,
  76. },
  77. build : {
  78. src : '<%= pkg.filename %>-all.js',
  79. dest : '<%= pkg.filename %>-all-min.js'
  80. }
  81. },
  82. compress : {
  83. main : {
  84. options: {
  85. archive: 'dist/<%= pkg.filename %>-<%= pkg.version %>-' + lang + '.zip',
  86. },
  87. files: [
  88. {src: ['asp/**'], dest: 'kindeditor/'},
  89. {src: ['asp.net/**'], dest: 'kindeditor/'},
  90. {src: ['attached'], dest: 'kindeditor/'},
  91. {src: ['jsp/**'], dest: 'kindeditor/'},
  92. {src: ['lang/**'], dest: 'kindeditor/'},
  93. {src: ['php/**'], dest: 'kindeditor/'},
  94. {src: ['plugins/**'], dest: 'kindeditor/'},
  95. {src: ['themes/**'], dest: 'kindeditor/'},
  96. {src: ['kindeditor*.js'], dest: 'kindeditor/'},
  97. {src: ['license.txt'], dest: 'kindeditor/'},
  98. ]
  99. }
  100. }
  101. });
  102. grunt.loadNpmTasks('grunt-contrib-concat');
  103. grunt.loadNpmTasks('grunt-contrib-uglify');
  104. grunt.loadNpmTasks('grunt-contrib-compress');
  105. grunt.registerTask('build', ['concat', 'uglify']);
  106. grunt.registerTask('zip', ['build', 'compress']);
  107. grunt.registerTask('default', 'build');
  108. };