openvidu-components: Reduced bundle size compressing code

pull/780/head
Carlos Santos 2023-02-24 12:08:54 +01:00
parent 90dfd60a06
commit 0cab779c8e
3 changed files with 662 additions and 12630 deletions

View File

@ -0,0 +1,20 @@
const glob = require('glob');
const { readFileSync, writeFileSync } = require('fs');
const { minify } = require('uglify-js');
const options = {
mangle: true,
compress: true,
toplevel: false,
output: {
comments: false
}
};
glob('dist/openvidu-angular/**/*.mjs', {}, function (er, files) {
files.forEach(function (file) {
const code = readFileSync(file, 'utf8');
const result = minify(code, options);
writeFileSync(file, result.code, 'utf8');
});
});

File diff suppressed because it is too large Load Diff

View File

@ -32,6 +32,7 @@
"codelyzer": "6.0.2", "codelyzer": "6.0.2",
"concat": "^1.0.3", "concat": "^1.0.3",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"glob": "^8.1.0",
"http-server": "14.1.1", "http-server": "14.1.1",
"jasmine-core": "3.10.1", "jasmine-core": "3.10.1",
"jasmine-spec-reporter": "7.0.0", "jasmine-spec-reporter": "7.0.0",
@ -50,32 +51,34 @@
"ts-node": "10.4.0", "ts-node": "10.4.0",
"tslint": "6.1.3", "tslint": "6.1.3",
"typescript": "4.8.4", "typescript": "4.8.4",
"uglify-js": "^3.17.4",
"webpack-bundle-analyzer": "^4.5.0" "webpack-bundle-analyzer": "^4.5.0"
}, },
"name": "openvidu-components-testapp", "name": "openvidu-components-testapp",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "ng build openvidu-components-testapp --configuration production", "build": "ng build openvidu-components-testapp --configuration production",
"bundle-report": "ng build openvidu-webcomponent --stats-json --configuration production && webpack-bundle-analyzer dist/openvidu-webcomponent/stats.json", "bundle-report": "ng build openvidu-webcomponent --stats-json --configuration production && webpack-bundle-analyzer dist/openvidu-webcomponent/stats.json",
"doc:build": "npx compodoc -c ./projects/openvidu-angular/doc/.compodocrc.json", "doc:build": "npx compodoc -c ./projects/openvidu-angular/doc/.compodocrc.json",
"doc:clean-copy": "rm -rf ../../openvidu.io-docs/docs/api/openvidu-angular && cp -r ./docs/openvidu-angular/ ../../openvidu.io-docs/docs/api/openvidu-angular", "doc:clean-copy": "rm -rf ../../openvidu.io-docs/docs/api/openvidu-angular && cp -r ./docs/openvidu-angular/ ../../openvidu.io-docs/docs/api/openvidu-angular",
"doc:serve": "npx compodoc --watch --serve -c ./projects/openvidu-angular/doc/.compodocrc.json", "doc:serve": "npx compodoc --watch --serve -c ./projects/openvidu-angular/doc/.compodocrc.json",
"lib:build": "ng build openvidu-angular --configuration production && cd ./dist/openvidu-angular && npm pack", "lib:build": "ng build openvidu-angular --configuration production && npm run lib:compress && cd ./dist/openvidu-angular && npm pack",
"lib:copy": "cp dist/openvidu-angular/openvidu-angular-*.tgz ../../openvidu-tutorials/openvidu-call/openvidu-call-front", "lib:compress": "node ./openvidu-angular-compress.js",
"lib:e2e": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/angular.test.js", "lib:copy": "cp dist/openvidu-angular/openvidu-angular-*.tgz ../../openvidu-tutorials/openvidu-call/openvidu-call-front",
"lib:e2e-ci": "cross-env LAUNCH_MODE=CI npm run lib:e2e", "lib:e2e": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/angular.test.js",
"lib:serve": "ng build openvidu-angular --watch", "lib:e2e-ci": "cross-env LAUNCH_MODE=CI npm run lib:e2e",
"lib:test": "ng test openvidu-angular --no-watch --code-coverage", "lib:serve": "ng build openvidu-angular --watch",
"lint": "ng lint", "lib:test": "ng test openvidu-angular --no-watch --code-coverage",
"start": "ng serve --configuration development", "lint": "ng lint",
"start-prod": "npx http-server ./dist/openvidu-components-testapp/ --port 4200", "start": "ng serve --configuration development",
"start:ssl": "ng serve --ssl --configuration development --host 0.0.0.0 --port 4200 --ssl-cert /path/to/cert.pem --ssl-key /path/to/key.pem", "start-prod": "npx http-server ./dist/openvidu-components-testapp/ --port 4200",
"webcomponent:build": "./node_modules/@angular/cli/bin/ng.js build openvidu-webcomponent --configuration production && node ./openvidu-webcomponent-build.js", "start:ssl": "ng serve --ssl --configuration development --host 0.0.0.0 --port 4200 --ssl-cert /path/to/cert.pem --ssl-key /path/to/key.pem",
"webcomponent:e2e": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/webcomponent.test.js", "webcomponent:build": "./node_modules/@angular/cli/bin/ng.js build openvidu-webcomponent --configuration production && node ./openvidu-webcomponent-build.js",
"webcomponent:e2e-ci": "cross-env LAUNCH_MODE=CI npm run webcomponent:e2e", "webcomponent:e2e": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/webcomponent.test.js",
"webcomponent:e2e-pro": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/webcomponent.pro.test.js", "webcomponent:e2e-ci": "cross-env LAUNCH_MODE=CI npm run webcomponent:e2e",
"webcomponent:e2e-pro-ci": "cross-env LAUNCH_MODE=CI npm run webcomponent:e2e-pro", "webcomponent:e2e-pro": "tsc --project ./e2e && npx mocha --recursive --timeout 30000 ./e2e/dist/webcomponent.pro.test.js",
"webcomponent:e2e-pro-ci": "cross-env LAUNCH_MODE=CI npm run webcomponent:e2e-pro",
"webcomponent:serve-testapp": "npx http-server ./e2e/webcomponent-app/ && echo http://localhost:8080/?OV_URL=https://localhost:4443&OV_SECRET=MY_SECRET&prejoin=false" "webcomponent:serve-testapp": "npx http-server ./e2e/webcomponent-app/ && echo http://localhost:8080/?OV_URL=https://localhost:4443&OV_SECRET=MY_SECRET&prejoin=false"
}, },
"version": "2.25.0" "version": "2.25.0"
} }