From b5beef8e043c08e0a1db4a1ab77a84f3a97bd80f Mon Sep 17 00:00:00 2001 From: 0age <37939117+0age@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:51:26 -0800 Subject: [PATCH] terser --- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 58 +++++++++++++++++++++++++++++++++++++---- frontend/vite.config.ts | 23 ++++++---------- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index f4bbce6..be94c8a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -34,6 +34,7 @@ "eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-react-refresh": "^0.4.16", "globals": "^15.13.0", + "terser": "^5.37.0", "typescript": "~5.7.2", "vite": "^6.0.3" } diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 109a9f6..90f859b 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -59,7 +59,7 @@ importers: version: 8.18.0(eslint@8.57.1)(typescript@5.7.2) '@vitejs/plugin-react': specifier: ^4.3.4 - version: 4.3.4(vite@6.0.3(jiti@2.4.1)(yaml@2.6.1)) + version: 4.3.4(vite@6.0.3(jiti@2.4.1)(terser@5.37.0)(yaml@2.6.1)) eslint: specifier: ^8.56.0 version: 8.57.1 @@ -75,12 +75,15 @@ importers: globals: specifier: ^15.13.0 version: 15.13.0 + terser: + specifier: ^5.37.0 + version: 5.37.0 typescript: specifier: ~5.7.2 version: 5.7.2 vite: specifier: ^6.0.3 - version: 6.0.3(jiti@2.4.1)(yaml@2.6.1) + version: 6.0.3(jiti@2.4.1)(terser@5.37.0)(yaml@2.6.1) packages: @@ -433,6 +436,9 @@ packages: resolution: {integrity: sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==} engines: {node: '>=6.0.0'} + '@jridgewell/source-map@0.3.6': + resolution: {integrity: sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==} + '@jridgewell/sourcemap-codec@1.5.0': resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} @@ -1254,6 +1260,9 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} @@ -1317,6 +1326,9 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + commander@2.20.3: + resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} @@ -2694,6 +2706,13 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + split-on-first@1.1.0: resolution: {integrity: sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==} engines: {node: '>=6'} @@ -2789,6 +2808,11 @@ packages: engines: {node: '>=14.0.0'} hasBin: true + terser@5.37.0: + resolution: {integrity: sha512-B8wRRkmre4ERucLM/uXx4MOV5cbnOlVAqUst+1+iLKPI0dOgFO28f84ptoQt9HEI537PMzfYa/d+GEPKTRXmYA==} + engines: {node: '>=10'} + hasBin: true + text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -3522,6 +3546,11 @@ snapshots: '@jridgewell/set-array@1.2.1': {} + '@jridgewell/source-map@0.3.6': + dependencies: + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/sourcemap-codec@1.5.0': {} '@jridgewell/trace-mapping@0.3.25': @@ -4246,14 +4275,14 @@ snapshots: dependencies: '@vanilla-extract/css': 1.15.5 - '@vitejs/plugin-react@4.3.4(vite@6.0.3(jiti@2.4.1)(yaml@2.6.1))': + '@vitejs/plugin-react@4.3.4(vite@6.0.3(jiti@2.4.1)(terser@5.37.0)(yaml@2.6.1))': dependencies: '@babel/core': 7.26.0 '@babel/plugin-transform-react-jsx-self': 7.25.9(@babel/core@7.26.0) '@babel/plugin-transform-react-jsx-source': 7.25.9(@babel/core@7.26.0) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 6.0.3(jiti@2.4.1)(yaml@2.6.1) + vite: 6.0.3(jiti@2.4.1)(terser@5.37.0)(yaml@2.6.1) transitivePeerDependencies: - supports-color @@ -4764,6 +4793,8 @@ snapshots: node-releases: 2.0.19 update-browserslist-db: 1.1.1(browserslist@4.24.2) + buffer-from@1.1.2: {} + buffer@6.0.3: dependencies: base64-js: 1.5.1 @@ -4836,6 +4867,8 @@ snapshots: color-name@1.1.4: {} + commander@2.20.3: {} + commander@4.1.1: {} concat-map@0.0.1: {} @@ -6367,6 +6400,13 @@ snapshots: source-map-js@1.2.1: {} + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + source-map@0.6.1: {} + split-on-first@1.1.0: {} split2@4.2.0: {} @@ -6497,6 +6537,13 @@ snapshots: transitivePeerDependencies: - ts-node + terser@5.37.0: + dependencies: + '@jridgewell/source-map': 0.3.6 + acorn: 8.14.0 + commander: 2.20.3 + source-map-support: 0.5.21 + text-table@0.2.0: {} thenify-all@1.6.0: @@ -6689,7 +6736,7 @@ snapshots: - utf-8-validate - zod - vite@6.0.3(jiti@2.4.1)(yaml@2.6.1): + vite@6.0.3(jiti@2.4.1)(terser@5.37.0)(yaml@2.6.1): dependencies: esbuild: 0.24.0 postcss: 8.4.49 @@ -6697,6 +6744,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 jiti: 2.4.1 + terser: 5.37.0 yaml: 2.6.1 wagmi@2.13.5(@tanstack/query-core@5.62.7)(@tanstack/react-query@5.62.7(react@18.3.1))(@types/react@18.3.15)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.7.2)(utf-8-validate@5.0.10)(viem@2.21.54(bufferutil@4.0.8)(typescript@5.7.2)(utf-8-validate@5.0.10)): diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 247b353..90a21d0 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,7 +1,6 @@ import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; -import { visualizer } from 'rollup-plugin-visualizer'; // https://vite.dev/config/ export default defineConfig(({ mode }) => { @@ -12,14 +11,7 @@ export default defineConfig(({ mode }) => { return { plugins: [ - react(), - visualizer({ - filename: 'dist/stats.html', - open: true, - gzipSize: true, - brotliSize: true, - template: 'treemap' - }) + react() ], server: { port: parseInt(devPort), @@ -37,13 +29,11 @@ export default defineConfig(({ mode }) => { 'process.env.BASE_URL': JSON.stringify(baseUrl), }, build: { - target: 'esnext', + target: 'es2020', minify: 'terser', terserOptions: { compress: { - drop_console: true, drop_debugger: true, - pure_getters: true, passes: 3, module: true, toplevel: true, @@ -64,8 +54,12 @@ export default defineConfig(({ mode }) => { indent_level: 0 } }, - chunkSizeWarningLimit: 375, reportCompressedSize: true, + chunkSizeWarningLimit: 400, + performance: { + maxEntrypointSize: 500000, + maxAssetSize: 500000 + }, cssCodeSplit: true, rollupOptions: { output: { @@ -178,7 +172,6 @@ export default defineConfig(({ mode }) => { compact: true, generatedCode: { preset: 'es2015', - symbols: false, constBindings: true } } @@ -192,7 +185,7 @@ export default defineConfig(({ mode }) => { legalComments: 'none', ignoreAnnotations: true, treeShaking: true, - target: 'esnext' + target: 'es2020' } }; });