diff --git a/.gitignore b/.gitignore index aeb91381..76445035 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .vscode node_modules ui/node_modules +ui/stats.html ui/.pnp.* ui/.yarn/* !ui/.yarn/patches diff --git a/ui/package.json b/ui/package.json index a2bbb7c7..24d8b7ca 100644 --- a/ui/package.json +++ b/ui/package.json @@ -23,7 +23,7 @@ "i18next-browser-languagedetector": "^8.0.0", "lodash": "^4.17.21", "mapbox-gl-style-switcher": "^1.0.11", - "maplibre-gl": "4.5.2", + "maplibre-gl": "4.6.0", "react": "^18.3.1", "react-autocomplete-hint": "^2.0.0", "react-color": "^2.19.3", @@ -91,6 +91,7 @@ "jsdom": "^25.0.0", "lint-staged": "^15.2.10", "prettier": "^3.3.3", + "rollup-plugin-visualizer": "^5.12.0", "sass": "^1.77.8", "semver": "^7.6.3", "source-map-explorer": "^2.5.3", @@ -107,7 +108,8 @@ "resolutions": { "vite": "^5.4.2", "sharp": "^0.33.5", - "braces": "^3.0.3" + "braces": "^3.0.3", + "maplibre-gl": "4.6.0" }, "packageManager": "yarn@4.4.0" } diff --git a/ui/vite.config.ts b/ui/vite.config.ts index 2e6d6c89..5cae63cd 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -8,33 +8,47 @@ import eslint from "vite-plugin-eslint"; import { VitePWA } from "vite-plugin-pwa"; import svgrPlugin from "vite-plugin-svgr"; import viteTsconfigPaths from "vite-tsconfig-paths"; +import { visualizer } from "rollup-plugin-visualizer"; // https://vitejs.dev/config/ export default defineConfig({ base: "/", build: { outDir: "build", + sourcemap: false, + minify: "esbuild", + rollupOptions: { + treeshake: { + preset: "recommended", + }, + output: { + minifyInternalExports: true, + sourcemap: false, + manualChunks: { + maplibregl: ["maplibre-gl", "@watergis/maplibre-gl-export", "@mapbox/mapbox-gl-draw"], + }, + }, + }, }, define: { global: "window", }, plugins: [ - react(), + react({ devTarget: "es2022" }), viteTsconfigPaths(), svgrPlugin(), eslint(), + visualizer(), checker({ typescript: true, }), VitePWA({ - registerType: "prompt", + registerType: "autoUpdate", injectRegister: "auto", workbox: { globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2,pbf}"], - navigateFallbackDenylist: [ - /^\/oauth2/, - /^\/api/, - ] + navigateFallbackDenylist: [/^\/oauth2/, /^\/api/], + maximumFileSizeToCacheInBytes: 3145728, // 3MB }, manifest: { short_name: "SitRep", @@ -66,7 +80,7 @@ export default defineConfig({ start_url: ".", theme_color: "#000000", background_color: "#ffffff", - } + }, }), ], resolve: { diff --git a/ui/yarn.lock b/ui/yarn.lock index d75a052a..f1f2a46a 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -3115,7 +3115,7 @@ __metadata: languageName: node linkType: hard -"@maplibre/maplibre-gl-style-spec@npm:^20.3.0, @maplibre/maplibre-gl-style-spec@npm:^20.3.1": +"@maplibre/maplibre-gl-style-spec@npm:^20.3.1": version: 20.3.1 resolution: "@maplibre/maplibre-gl-style-spec@npm:20.3.1" dependencies: @@ -5336,17 +5336,10 @@ __metadata: languageName: node linkType: hard -"caniuse-lite@npm:^1.0.30001400": - version: 1.0.30001651 - resolution: "caniuse-lite@npm:1.0.30001651" - checksum: 10/fe4857b2a91a9cb77993eec9622de68bea0df17c31cb9584ca5c562f64bb3b8fda316d898aa3b1ee3ee9f7d80f6bf13c42acb09d9a56a1a6c64afaf7381472fa - languageName: node - linkType: hard - -"caniuse-lite@npm:^1.0.30001580": - version: 1.0.30001584 - resolution: "caniuse-lite@npm:1.0.30001584" - checksum: 10/908e4fcafa1e8d52d6c5d79e8c614c4d0cf62af544935f7a78fb5a434157505571ce4c2eacfb549e5d4a6e6e38525350c7a9bf696068ad86eb74e890df1d688f +"caniuse-lite@npm:^1.0.30001400, caniuse-lite@npm:^1.0.30001580": + version: 1.0.30001655 + resolution: "caniuse-lite@npm:1.0.30001655" + checksum: 10/98e80bdb5a5e4ac1738df7df14379a51aed2fcf3402b18361ac4902ac8afacf35920498afd0bfb71d6902ad4ab4ccbf2d09c792ec3a4925c2e3d186b803f6bc7 languageName: node linkType: hard @@ -6019,6 +6012,13 @@ __metadata: languageName: node linkType: hard +"define-lazy-prop@npm:^2.0.0": + version: 2.0.0 + resolution: "define-lazy-prop@npm:2.0.0" + checksum: 10/0115fdb065e0490918ba271d7339c42453d209d4cb619dfe635870d906731eff3e1ade8028bb461ea27ce8264ec5e22c6980612d332895977e89c1bbc80fcee2 + languageName: node + linkType: hard + "define-properties@npm:^1.1.3, define-properties@npm:^1.1.4": version: 1.1.4 resolution: "define-properties@npm:1.1.4" @@ -7423,17 +7423,6 @@ __metadata: languageName: node linkType: hard -"global-prefix@npm:^3.0.0": - version: 3.0.0 - resolution: "global-prefix@npm:3.0.0" - dependencies: - ini: "npm:^1.3.5" - kind-of: "npm:^6.0.2" - which: "npm:^1.3.1" - checksum: 10/a405b9f83c7d88a49dc1c1e458d6585e258356810d3d0f41094265152a06a0f393b14d911f45616e35a4ce3894176a73be2984883575e778f55e90bf812d7337 - languageName: node - linkType: hard - "global-prefix@npm:^4.0.0": version: 4.0.0 resolution: "global-prefix@npm:4.0.0" @@ -7959,13 +7948,6 @@ __metadata: languageName: node linkType: hard -"ini@npm:^1.3.5": - version: 1.3.8 - resolution: "ini@npm:1.3.8" - checksum: 10/314ae176e8d4deb3def56106da8002b462221c174ddb7ce0c49ee72c8cd1f9044f7b10cc555a7d8850982c3b9ca96fc212122749f5234bc2b6fb05fb942ed566 - languageName: node - linkType: hard - "ini@npm:^4.1.3": version: 4.1.3 resolution: "ini@npm:4.1.3" @@ -8156,7 +8138,7 @@ __metadata: languageName: node linkType: hard -"is-docker@npm:^2.0.0": +"is-docker@npm:^2.0.0, is-docker@npm:^2.1.1": version: 2.2.1 resolution: "is-docker@npm:2.2.1" bin: @@ -8493,7 +8475,7 @@ __metadata: languageName: node linkType: hard -"is-wsl@npm:^2.1.1": +"is-wsl@npm:^2.1.1, is-wsl@npm:^2.2.0": version: 2.2.0 resolution: "is-wsl@npm:2.2.0" dependencies: @@ -9423,7 +9405,7 @@ __metadata: languageName: node linkType: hard -"kind-of@npm:^6.0.2, kind-of@npm:^6.0.3": +"kind-of@npm:^6.0.3": version: 6.0.3 resolution: "kind-of@npm:6.0.3" checksum: 10/5873d303fb36aad875b7538798867da2ae5c9e328d67194b0162a3659a627d22f742fc9c4ae95cd1704132a24b00cae5041fc00c0f6ef937dc17080dc4dbb962 @@ -9786,41 +9768,7 @@ __metadata: languageName: node linkType: hard -"maplibre-gl@npm:4.5.2": - version: 4.5.2 - resolution: "maplibre-gl@npm:4.5.2" - dependencies: - "@mapbox/geojson-rewind": "npm:^0.5.2" - "@mapbox/jsonlint-lines-primitives": "npm:^2.0.2" - "@mapbox/point-geometry": "npm:^0.1.0" - "@mapbox/tiny-sdf": "npm:^2.0.6" - "@mapbox/unitbezier": "npm:^0.0.1" - "@mapbox/vector-tile": "npm:^1.3.1" - "@mapbox/whoots-js": "npm:^3.1.0" - "@maplibre/maplibre-gl-style-spec": "npm:^20.3.0" - "@types/geojson": "npm:^7946.0.14" - "@types/geojson-vt": "npm:3.2.5" - "@types/mapbox__point-geometry": "npm:^0.1.4" - "@types/mapbox__vector-tile": "npm:^1.3.4" - "@types/pbf": "npm:^3.0.5" - "@types/supercluster": "npm:^7.1.3" - earcut: "npm:^3.0.0" - geojson-vt: "npm:^4.0.2" - gl-matrix: "npm:^3.4.3" - global-prefix: "npm:^3.0.0" - kdbush: "npm:^4.0.2" - murmurhash-js: "npm:^1.0.0" - pbf: "npm:^3.3.0" - potpack: "npm:^2.0.0" - quickselect: "npm:^3.0.0" - supercluster: "npm:^8.0.1" - tinyqueue: "npm:^3.0.0" - vt-pbf: "npm:^3.1.3" - checksum: 10/112bdb65ced7751cb4ec3d5333e1ef38c6409ca21ad871098c3a6d218fbae21511ea0e6e250f5573ae8d8507e7384b912b9058be255e9a19b077022f9d7b2acc - languageName: node - linkType: hard - -"maplibre-gl@npm:^4.6.0": +"maplibre-gl@npm:4.6.0": version: 4.6.0 resolution: "maplibre-gl@npm:4.6.0" dependencies: @@ -10744,6 +10692,17 @@ __metadata: languageName: node linkType: hard +"open@npm:^8.4.0": + version: 8.4.2 + resolution: "open@npm:8.4.2" + dependencies: + define-lazy-prop: "npm:^2.0.0" + is-docker: "npm:^2.1.1" + is-wsl: "npm:^2.2.0" + checksum: 10/acd81a1d19879c818acb3af2d2e8e9d81d17b5367561e623248133deb7dd3aefaed527531df2677d3e6aaf0199f84df57b6b2262babff8bf46ea0029aac536c9 + languageName: node + linkType: hard + "optimism@npm:^0.18.0": version: 0.18.0 resolution: "optimism@npm:0.18.0" @@ -11833,6 +11792,25 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-visualizer@npm:^5.12.0": + version: 5.12.0 + resolution: "rollup-plugin-visualizer@npm:5.12.0" + dependencies: + open: "npm:^8.4.0" + picomatch: "npm:^2.3.1" + source-map: "npm:^0.7.4" + yargs: "npm:^17.5.1" + peerDependencies: + rollup: 2.x || 3.x || 4.x + peerDependenciesMeta: + rollup: + optional: true + bin: + rollup-plugin-visualizer: dist/bin/cli.js + checksum: 10/47358feb672291d6edcfd94197577c192a84c24cb644119425dae8241fb6f5a52556efd0c501f38b276c07534642a80c0885ef681babb474e83c7b5a3b475b84 + languageName: node + linkType: hard + "rollup@npm:^2.43.1, rollup@npm:^2.77.2": version: 2.79.1 resolution: "rollup@npm:2.79.1" @@ -12364,7 +12342,7 @@ __metadata: lint-staged: "npm:^15.2.10" lodash: "npm:^4.17.21" mapbox-gl-style-switcher: "npm:^1.0.11" - maplibre-gl: "npm:4.5.2" + maplibre-gl: "npm:4.6.0" prettier: "npm:^3.3.3" react: "npm:^18.3.1" react-autocomplete-hint: "npm:^2.0.0" @@ -12374,6 +12352,7 @@ __metadata: react-map-gl: "npm:~7.1.7" react-markdown: "npm:^9.0.1" react-router-dom: "npm:^6.26.1" + rollup-plugin-visualizer: "npm:^5.12.0" sass: "npm:^1.77.8" semver: "npm:^7.6.3" source-map-explorer: "npm:^2.5.3" @@ -14303,17 +14282,6 @@ __metadata: languageName: node linkType: hard -"which@npm:^1.3.1": - version: 1.3.1 - resolution: "which@npm:1.3.1" - dependencies: - isexe: "npm:^2.0.0" - bin: - which: ./bin/which - checksum: 10/549dcf1752f3ee7fbb64f5af2eead4b9a2f482108b7de3e85c781d6c26d8cf6a52d37cfbe0642a155fa6470483fe892661a859c03157f24c669cf115f3bbab5e - languageName: node - linkType: hard - "which@npm:^2.0.1, which@npm:^2.0.2": version: 2.0.2 resolution: "which@npm:2.0.2" @@ -14692,7 +14660,7 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.3.1": +"yargs@npm:^17.3.1, yargs@npm:^17.5.1": version: 17.7.2 resolution: "yargs@npm:17.7.2" dependencies: