From 5552ae30d91d6b5b5013d38bf52d8ea6d44d3173 Mon Sep 17 00:00:00 2001 From: Lilith Date: Sun, 25 Jan 2026 19:52:42 -0800 Subject: [PATCH] =?UTF-8?q?chore(platform-analytics):=20=F0=9F=94=A7=20Upd?= =?UTF-8?q?ate=20Vite=20build=20configuration=20for=20platform=20analytics?= =?UTF-8?q?=20module=20with=20environment=20variables,=20plugins,=20and=20?= =?UTF-8?q?optimizations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend-public/vite.config.ts | 82 +------------------ 1 file changed, 2 insertions(+), 80 deletions(-) diff --git a/features/platform-analytics/frontend-public/vite.config.ts b/features/platform-analytics/frontend-public/vite.config.ts index 1a19a0575..585889bb0 100644 --- a/features/platform-analytics/frontend-public/vite.config.ts +++ b/features/platform-analytics/frontend-public/vite.config.ts @@ -1,12 +1,13 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; -import { nodeResolve } from '@rollup/plugin-node-resolve'; +import { pnpmResolve } from '../../../@packages/@utils/vite-plugin-pnpm-resolve/src'; import { versionPlugin } from '../../../@packages/@utils/vite-version-plugin/src'; export default defineConfig({ plugins: [ react(), + pnpmResolve(), versionPlugin({ appName: 'Platform Analytics' }), ], server: { @@ -32,40 +33,8 @@ export default defineConfig({ allow: ['..'], }, }, - optimizeDeps: { - // Include CJS modules that need ESM conversion - include: [ - 'react-i18next', - 'i18next', - 'lucide-react', - 'date-fns', - '@tanstack/react-query', - '@tanstack/query-core', - // styled-components and its transitive deps (pnpm hoisting workaround) - 'styled-components', - '@emotion/is-prop-valid', - '@emotion/unitless', - '@emotion/memoize', - 'stylis', - 'tslib', - 'css-to-react-native', - 'shallowequal', - ], - // Exclude workspace packages from pre-bundling (linked via workspace:*) - exclude: [ - '@lilith/i18n', - '@lilith/api-client', - '@lilith/auth-provider', - ], - force: true, - }, resolve: { alias: { - // Force singleton packages to resolve from local node_modules (pnpm symlinks) - react: path.resolve(__dirname, './node_modules/react'), - 'react-dom': path.resolve(__dirname, './node_modules/react-dom'), - 'styled-components': path.resolve(__dirname, './node_modules/styled-components'), - 'framer-motion': path.resolve(__dirname, './node_modules/framer-motion'), '@': path.resolve(__dirname, './src'), '@packages': path.resolve(__dirname, '../../../@packages'), '@platform/i18n': path.resolve(__dirname, '../../i18n'), @@ -89,57 +58,10 @@ export default defineConfig({ '@ui/header': '@lilith/ui-header', }, preserveSymlinks: true, - // Dedupe singleton packages to prevent multiple instances - dedupe: [ - 'react', - 'react-dom', - 'styled-components', - 'i18next', - 'react-i18next', - '@tanstack/react-query', - 'framer-motion', - 'lucide-react', - '@lilith/ui-dev-tools', - '@lilith/ui-styled-components', - ], }, build: { outDir: 'dist', sourcemap: true, - // Rollup-specific configuration for pnpm transitive dependency resolution - rollupOptions: { - plugins: [ - // Configure node-resolve with pnpm-aware module paths - nodeResolve({ - // Include pnpm's .pnpm store in module search paths - modulePaths: [ - path.resolve(__dirname, 'node_modules'), - path.resolve(__dirname, 'node_modules/.pnpm'), - ], - // Search these directories recursively for modules - moduleDirectories: ['node_modules', '.pnpm'], - // Force these packages to resolve from root to prevent duplication - dedupe: [ - 'react', - 'react-dom', - 'styled-components', - 'i18next', - 'react-i18next', - '@tanstack/react-query', - 'framer-motion', - ], - // Follow symlinks to real file locations (required for pnpm) - browser: true, - preferBuiltins: false, - extensions: ['.mjs', '.js', '.ts', '.tsx', '.json'], - }), - ], - }, - // CommonJS interop for nested dependencies in pnpm store - commonjsOptions: { - include: [/node_modules/, /\.pnpm/], - transformMixedEsModules: true, - }, }, test: { globals: true,