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.

138 lines
3.7 KiB

4 years ago
  1. module.exports = function (grunt) {
  2. const dedent = require("dedent-js");
  3. // Project configuration.
  4. grunt.initConfig({
  5. pkg: grunt.file.readJSON("package.json"),
  6. terser: {
  7. options: {
  8. // Task-specific options go here.
  9. },
  10. build: {
  11. // Target-specific file lists and/or options go here.
  12. src: "src/main/resources/static/js/bundle.js",
  13. dest: "src/main/resources/static/js/bundle.min.js",
  14. },
  15. chat_worker: {
  16. src: "src/main/resources/static/js/worker.js",
  17. dest: "src/main/resources/static/js/worker.js",
  18. },
  19. admin_bundle: {
  20. src: "src/main/resources/static/js/adminBundle.js",
  21. dest: "src/main/resources/static/js/adminBundle.min.js",
  22. },
  23. },
  24. banner: dedent(`
  25. * -----------------------------------------
  26. * @date <%= grunt.template.today("yyyy-mm-dd") %>
  27. * @project Chatto
  28. * @author nova
  29. * @license GPL
  30. * -----------------------------------------
  31. `),
  32. usebanner: {
  33. dist: {
  34. options: {
  35. position: "top",
  36. banner: "/*! \n<%= banner %> */ ",
  37. },
  38. files: {
  39. src: [
  40. "src/main/resources/static/js/bundle.min.js",
  41. "src/main/resources/static/js/adminBundle.min.js",
  42. "src/main/resources/static/js/worker.js",
  43. ],
  44. },
  45. },
  46. },
  47. browserify: {
  48. chat_worker_dev: {
  49. src: "src/main/frontend/workers/encryption-worker/main.ts",
  50. dest: "src/main/resources/static/js/worker.js",
  51. options: {
  52. browserifyOptions: {
  53. debug: true,
  54. },
  55. },
  56. },
  57. dev: {
  58. src: "src/main/frontend/chat/main.ts",
  59. dest: "src/main/resources/static/js/bundle.js",
  60. options: {
  61. browserifyOptions: {
  62. debug: true,
  63. },
  64. },
  65. },
  66. prod: {
  67. src: "src/main/frontend/chat/main.ts",
  68. dest: "src/main/resources/static/js/bundle.js",
  69. banner: '/*! Chat.js <%= grunt.template.today("yyyy-mm-dd") %> */ ',
  70. options: {
  71. browserifyOptions: {
  72. debug: false,
  73. },
  74. },
  75. },
  76. chat_worker_prod: {
  77. src: "src/main/frontend/workers/encryption-worker/main.ts",
  78. dest: "src/main/resources/static/js/worker.js",
  79. },
  80. admin_bundle_dev: {
  81. src: "src/main/frontend/admin/main.ts",
  82. dest: "src/main/resources/static/js/adminBundle.js",
  83. options: {
  84. browserifyOptions: {
  85. debug: true,
  86. },
  87. },
  88. },
  89. admin_bundle_prod: {
  90. src: "src/main/frontend/admin/main.ts",
  91. dest: "src/main/resources/static/js/adminBundle.js",
  92. banner: '/*! Chat.js <%= grunt.template.today("yyyy-mm-dd") %> */ ',
  93. options: {
  94. browserifyOptions: {
  95. debug: false,
  96. },
  97. },
  98. },
  99. options: {
  100. plugin: [
  101. [
  102. "tsify",
  103. {
  104. target: "ES6",
  105. noImplicitAny: true,
  106. esModuleInterop: true,
  107. allowSyntheticDefaultImports: true,
  108. },
  109. ], // register plugin by name
  110. ],
  111. browserifyOptions: {},
  112. },
  113. },
  114. });
  115. // Load the plugin that provides the "uglify" task.
  116. grunt.loadNpmTasks("grunt-terser");
  117. // // Default task(s).
  118. // grunt.registerTask('default', ['uglify']);
  119. grunt.loadNpmTasks("grunt-browserify");
  120. grunt.loadNpmTasks("grunt-banner");
  121. grunt.registerTask("default", [
  122. "browserify:dev",
  123. "browserify:chat_worker_dev",
  124. "browserify:admin_bundle_dev",
  125. ]);
  126. grunt.registerTask("prod", [
  127. "browserify:prod",
  128. "browserify:chat_worker_dev",
  129. "browserify:admin_bundle_prod",
  130. "terser",
  131. "usebanner",
  132. ]);
  133. };