Gruntfile.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json'),
  4. jshint: {
  5. cdtexteditor: ['src/cdtexteditor/cdtexteditor.js']
  6. },
  7. csslint: {
  8. cdtexteditor: {
  9. src: ['src/cdtexteditor/cdtexteditor.css']
  10. }
  11. },
  12. concat: {
  13. js: {
  14. options: {
  15. banner: "'use strict';\n",
  16. process: function(src, filepath) {
  17. return '// Source: ' + filepath + '\n' +
  18. src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
  19. }
  20. },
  21. src: [
  22. "src/codemirror/codemirror.js",
  23. "src/codemirror/mode/markdown/markdown.js",
  24. "src/codemirror/addon/hint/show-hint.js",
  25. "src/showdown-1.9.1/showdown.js",
  26. "src/typo/typo.js",
  27. "src/cdtexteditor/cdtexteditor.js",
  28. ],
  29. dest: 'build/<%= pkg.name %>.js'
  30. },
  31. css: {
  32. options: {
  33. banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
  34. },
  35. src: [
  36. "src/codemirror/codemirror.css",
  37. "src/codemirror/addon/hint/show-hint.css",
  38. "src/cdtexteditor/cdtexteditor.css"
  39. ],
  40. dest: 'build/<%= pkg.name %>.css'
  41. }
  42. },
  43. uglify: {
  44. options: {
  45. banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
  46. },
  47. js: {
  48. src: 'build/<%= pkg.name %>.js',
  49. dest: 'dist/<%= pkg.name %>.min.js'
  50. }
  51. },
  52. cssmin: {
  53. options: {
  54. banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
  55. },
  56. target: {
  57. src: 'build/<%= pkg.name %>.css',
  58. dest: 'dist/<%= pkg.name %>.min.css'
  59. }
  60. },
  61. clean: ['build'],
  62. copy: {
  63. assets: {
  64. expand: true,
  65. cwd: 'src/cdtexteditor/assets/',
  66. src: ['**'],
  67. dest: 'dist/assets/'
  68. }
  69. }
  70. });
  71. grunt.loadNpmTasks('grunt-contrib-clean');
  72. grunt.loadNpmTasks('grunt-contrib-jshint');
  73. grunt.loadNpmTasks('grunt-contrib-csslint');
  74. grunt.loadNpmTasks('grunt-contrib-concat');
  75. grunt.loadNpmTasks('grunt-contrib-uglify');
  76. grunt.loadNpmTasks('grunt-contrib-cssmin');
  77. grunt.loadNpmTasks('grunt-contrib-copy');
  78. grunt.registerTask('lint', ['jshint', 'csslint']);
  79. grunt.registerTask('default', ['jshint', 'csslint', 'concat', 'uglify', 'cssmin', 'copy', 'clean'])
  80. grunt.registerTask('build', ['concat', 'uglify', 'cssmin', 'copy', 'clean']);
  81. };