From a6002d5f195c6eccf321e6c96d4a5e35f77594fd Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Tue, 6 Aug 2024 22:08:36 +0800 Subject: [PATCH] refactor: produce br outputs (#6376) * refactor: produce br outputs * refactor: fix favicon url --- packages/console/vite.config.ts | 1 + packages/demo-app/index.html | 2 +- packages/demo-app/package.json | 2 ++ packages/demo-app/vite.config.ts | 15 +++++++++++---- packages/experience/vite.config.ts | 7 ++++++- pnpm-lock.yaml | 6 ++++++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/console/vite.config.ts b/packages/console/vite.config.ts index 27d6fb8aca6..ef82acea145 100644 --- a/packages/console/vite.config.ts +++ b/packages/console/vite.config.ts @@ -41,6 +41,7 @@ const buildConfig = (mode: string): UserConfig => ({ react(), svgr(), viteCompression({ disable: mode === 'development' }), + viteCompression({ disable: mode === 'development', algorithm: 'brotliCompress' }), ], define: { 'import.meta.env.IS_CLOUD': JSON.stringify(process.env.IS_CLOUD), diff --git a/packages/demo-app/index.html b/packages/demo-app/index.html index 188fa3eff52..ea0dc707926 100644 --- a/packages/demo-app/index.html +++ b/packages/demo-app/index.html @@ -4,7 +4,7 @@ - + Logto Live Preview diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index 7128bfb0536..70925eda438 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -31,6 +31,7 @@ "@silverhand/ts-config-react": "6.0.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "@vitejs/plugin-react": "^4.3.1", "eslint": "^8.56.0", "i18next": "^22.4.15", "i18next-browser-languagedetector": "^8.0.0", @@ -43,6 +44,7 @@ "stylelint": "^15.0.0", "typescript": "^5.5.3", "vite": "^5.3.4", + "vite-plugin-compression": "^0.5.1", "zod": "^3.23.8" }, "engines": { diff --git a/packages/demo-app/vite.config.ts b/packages/demo-app/vite.config.ts index 9fa6033fbf2..791276bf7f9 100644 --- a/packages/demo-app/vite.config.ts +++ b/packages/demo-app/vite.config.ts @@ -1,8 +1,10 @@ -import { mergeConfig, type UserConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import { mergeConfig, defineConfig, type UserConfig } from 'vite'; +import viteCompression from 'vite-plugin-compression'; import { defaultConfig } from '../../vite.shared.config'; -const config: UserConfig = { +const buildConfig = (mode: string): UserConfig => ({ base: '/demo-app', server: { port: 5003, @@ -10,6 +12,11 @@ const config: UserConfig = { port: 6003, }, }, -}; + plugins: [ + react(), + viteCompression({ disable: mode === 'development' }), + viteCompression({ disable: mode === 'development', algorithm: 'brotliCompress' }), + ], +}); -export default mergeConfig(defaultConfig, config); +export default defineConfig(({ mode }) => mergeConfig(defaultConfig, buildConfig(mode))); diff --git a/packages/experience/vite.config.ts b/packages/experience/vite.config.ts index fd98110b280..69d98afc845 100644 --- a/packages/experience/vite.config.ts +++ b/packages/experience/vite.config.ts @@ -20,7 +20,12 @@ const buildConfig = (mode: string): UserConfig => ({ mode === 'development' ? '__[hash:base64:5]__[local]' : '[hash:base64:5]_[local]', }, }, - plugins: [react(), svgr(), viteCompression({ disable: mode === 'development' })], + plugins: [ + react(), + svgr(), + viteCompression({ disable: mode === 'development' }), + viteCompression({ disable: mode === 'development', algorithm: 'brotliCompress' }), + ], build: { // Use the same browserslist configuration as in README.md. // Consider using the esbuild target directly in the future. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8c925a78d3b..f34ad8f3afd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3036,6 +3036,9 @@ importers: '@types/react-dom': specifier: ^18.3.0 version: 18.3.0 + '@vitejs/plugin-react': + specifier: ^4.3.1 + version: 4.3.1(vite@5.3.4(@types/node@20.12.7)(lightningcss@1.25.1)(sass@1.77.8)) eslint: specifier: ^8.56.0 version: 8.57.0 @@ -3072,6 +3075,9 @@ importers: vite: specifier: ^5.3.4 version: 5.3.4(@types/node@20.12.7)(lightningcss@1.25.1)(sass@1.77.8) + vite-plugin-compression: + specifier: ^0.5.1 + version: 0.5.1(vite@5.3.4(@types/node@20.12.7)(lightningcss@1.25.1)(sass@1.77.8)) zod: specifier: ^3.23.8 version: 3.23.8