A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.2 KiB

4 years ago
4 years ago
  1. module.exports = function (grunt) {
  2. // Project configuration.
  3. grunt.initConfig({
  4. pkg: grunt.file.readJSON('package.json'),
  5. terser: {
  6. options: {
  7. // Task-specific options go here.
  8. },
  9. build: {
  10. // Target-specific file lists and/or options go here.
  11. src: 'src/main/resources/static/js/bundle.js',
  12. dest: 'src/main/resources/static/js/bundle.min.js'
  13. },
  14. chat_worker: {
  15. src: 'src/main/resources/static/js/worker.js',
  16. dest: 'src/main/resources/static/js/worker.js'
  17. },
  18. },
  19. banner: `
  20. * -----------------------------------------
  21. * @date <%= grunt.template.today("yyyy-mm-dd") %>
  22. * @project Chatto
  23. * @author nova
  24. * @license GPL
  25. * -----------------------------------------
  26. `,
  27. usebanner: {
  28. dist: {
  29. options: {
  30. position: 'top',
  31. banner: '/*! <%= banner %> */ '
  32. },
  33. files: {
  34. src: ['src/main/resources/static/js/bundle.min.js', 'src/main/resources/static/js/worker.js']
  35. }
  36. }
  37. },
  38. browserify: {
  39. chat_worker_dev: {
  40. src: 'src/main/frontend/workers/encryption-worker/main.ts',
  41. dest: 'src/main/resources/static/js/worker.js',
  42. options: {
  43. browserifyOptions: {
  44. debug: true
  45. },
  46. }
  47. },
  48. dev: {
  49. src: 'src/main/frontend/chat/main.ts',
  50. dest: 'src/main/resources/static/js/bundle.js',
  51. options: {
  52. browserifyOptions: {
  53. debug: true
  54. },
  55. }
  56. },
  57. prod: {
  58. src: 'src/main/frontend/chat/main.ts',
  59. dest: 'src/main/resources/static/js/bundle.js',
  60. banner: '/*! Chat.js <%= grunt.template.today("yyyy-mm-dd") %> */ ',
  61. options: {
  62. browserifyOptions: {
  63. debug: false
  64. },
  65. }
  66. },
  67. chat_worker_prod: {
  68. src: 'src/main/frontend/workers/encryption-worker/main.ts',
  69. dest: 'src/main/resources/static/js/worker.min.js',
  70. },
  71. options: {
  72. plugin: [
  73. ['tsify', { target: 'ES6', noImplicitAny: true, esModuleInterop: true, allowSyntheticDefaultImports: true }], // register plugin by name
  74. ],
  75. browserifyOptions: {},
  76. }
  77. }
  78. });
  79. // Load the plugin that provides the "uglify" task.
  80. grunt.loadNpmTasks('grunt-terser');
  81. // // Default task(s).
  82. // grunt.registerTask('default', ['uglify']);
  83. grunt.loadNpmTasks('grunt-browserify')
  84. grunt.loadNpmTasks('grunt-banner');
  85. grunt.registerTask('default', ['browserify:dev', 'browserify:chat_worker_dev'])
  86. grunt.registerTask('prod', ["browserify:prod", 'browserify:chat_worker_dev', "terser", 'usebanner'])
  87. };