chore(platform-analytics): 🔧 Update Vite build configuration for platform analytics module with environment variables, plugins, and optimizations
This commit is contained in:
parent
65c0c1c3fc
commit
5552ae30d9
1 changed files with 2 additions and 80 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue