added chat worker prod bundle

This commit is contained in:
Rohan Sircar 2020-07-26 12:41:57 +05:30
parent ecfcecb53c
commit 3eb617f272
7 changed files with 27 additions and 12 deletions

2
.gitignore vendored
View File

@ -36,6 +36,8 @@ bundle.min.js
adminBundle.js
adminBundle.min.js
worker.js
chatWorker.js
chatWorker.min.js
node
src/main/javascript/node/
dist

View File

@ -13,8 +13,8 @@ module.exports = function (grunt) {
dest: "src/main/resources/static/js/bundle.min.js",
},
chat_worker: {
src: "src/main/resources/static/js/worker.js",
dest: "src/main/resources/static/js/worker.js",
src: "src/main/resources/static/js/chatWorker.js",
dest: "src/main/resources/static/js/chatWorker.min.js",
},
admin_bundle: {
src: "src/main/resources/static/js/adminBundle.js",
@ -22,24 +22,26 @@ module.exports = function (grunt) {
},
},
banner: dedent(`
/*
* -----------------------------------------
* @date <%= grunt.template.today("yyyy-mm-dd") %>
* @project Chatto
* @author nova
* @license GPL
* -----------------------------------------
*/
`),
usebanner: {
dist: {
options: {
position: "top",
banner: "/*! \n<%= banner %> */ ",
banner: "<%= banner %>",
},
files: {
src: [
"src/main/resources/static/js/bundle.min.js",
"src/main/resources/static/js/adminBundle.min.js",
"src/main/resources/static/js/worker.js",
"src/main/resources/static/js/chatWorker.min.js",
],
},
},
@ -47,7 +49,7 @@ module.exports = function (grunt) {
browserify: {
chat_worker_dev: {
src: "src/main/frontend/workers/encryption-worker/main.ts",
dest: "src/main/resources/static/js/worker.js",
dest: "src/main/resources/static/js/chatWorker.js",
options: {
browserifyOptions: {
debug: true,
@ -75,7 +77,7 @@ module.exports = function (grunt) {
},
chat_worker_prod: {
src: "src/main/frontend/workers/encryption-worker/main.ts",
dest: "src/main/resources/static/js/worker.js",
dest: "src/main/resources/static/js/chatWorker.js",
},
admin_bundle_dev: {
src: "src/main/frontend/admin/main.ts",

View File

@ -4,9 +4,13 @@ import { SJCLEncryptionService } from "./SJCLEncryptionService";
import PromiseWorker from "promise-worker";
export class EncryptionServiceFactory {
private static readonly _worker = new Worker('/js/worker.js');
private static readonly _promiseWorker = new PromiseWorker(EncryptionServiceFactory._worker);
public static getEncryptionService(): EncryptionService {
return new SJCLEncryptionService(this._promiseWorker)
}
private static readonly _worker = new Worker(
localStorage.getItem("CHAT_WORKER_BUNDLE") || "chat-worker-error.js"
);
private static readonly _promiseWorker = new PromiseWorker(
EncryptionServiceFactory._worker
);
public static getEncryptionService(): EncryptionService {
return new SJCLEncryptionService(this._promiseWorker);
}
}

View File

@ -7,4 +7,5 @@ spring.http.log-request-details=false
logging.level.org.springframework.cache = INFO
chat-bundle=bundle.min.js
admin-bundle=adminBundle.min.js
chat-worker-bundle=chatWorker.min.js
chatto.frontend.log-level=INFO

View File

@ -29,6 +29,7 @@ logging.level.org.springframework.cache=DEBUG
chatto.token.timeout-duration=30
chat-bundle=bundle.js
admin-bundle=adminBundle.js
chat-worker-bundle=chatWorker.js
# spring.devtools.add-properties=false
chatto.frontend.log-level=TRACE
chatto.frontend.chat-page-size=9

View File

@ -13,6 +13,8 @@
</div>
<script src="./../../javascript/bundle.js" th:src="@{'/js/' + ${@environment.getProperty('chat-bundle')}}"
defer></script>
<script src="./../../javascript/bundle.js" th:src="@{'/js/' + ${@environment.getProperty('chat-worker-bundle')}}"
defer></script>
<link rel="stylesheet" th:href="@{/css/chat.css}" href="../../resources/static/css/chat.css">
</head>

View File

@ -64,6 +64,9 @@
let loglevel = /*[[${@environment.getProperty('chatto.frontend.log-level')}]]*/ "DEBUG";
window.log.setLevel(loglevel)
let chatWorkerBundle = /*[[${@environment.getProperty('chat-worker-bundle')}]]*/ "chatWorker.js";
localStorage.setItem('CHAT_WORKER_BUNDLE', "/js/" + chatWorkerBundle)
let chatPageSize = /*[[${@environment.getProperty('chatto.frontend.chat-page-size')}]]*/ 9;
localStorage.setItem("CHAT_PAGE_SIZE", chatPageSize);
</script>