chore(fontend-dev): 🔧 Update frontend dependency versions to latest stable releases
This commit is contained in:
parent
7778bd3d05
commit
2fd3f24423
1 changed files with 53 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
import { versionPlugin } from '../../../@packages/@utils/vite-version-plugin/src';
|
||||
|
|
@ -57,15 +58,66 @@ const ignoreStyledDtsPlugin = {
|
|||
}
|
||||
};
|
||||
|
||||
// Plugin to resolve @/ imports based on importer's feature location
|
||||
const featureAliasPlugin = {
|
||||
name: 'feature-alias-resolver',
|
||||
resolveId(source: string, importer: string | undefined) {
|
||||
if (!source.startsWith('@/') || !importer) return null;
|
||||
|
||||
// Map of feature paths to their src directories
|
||||
const featureMap: Record<string, string> = {
|
||||
'seo/frontend-admin': path.resolve(__dirname, '../../seo/frontend-admin/src'),
|
||||
'truth-validation/frontend-admin': path.resolve(__dirname, '../../truth-validation/frontend-admin/src'),
|
||||
};
|
||||
|
||||
// Find which feature the importer belongs to
|
||||
let srcPath = path.resolve(__dirname, './src'); // default
|
||||
for (const [featurePath, featureSrcPath] of Object.entries(featureMap)) {
|
||||
if (importer.includes(featurePath)) {
|
||||
srcPath = featureSrcPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const relativePath = source.slice(2); // Remove @/
|
||||
let resolvedPath = path.resolve(srcPath, relativePath);
|
||||
|
||||
// Check if it's a directory and look for index file
|
||||
try {
|
||||
const stat = fs.statSync(resolvedPath);
|
||||
if (stat.isDirectory()) {
|
||||
// Try index.tsx first, then index.ts
|
||||
for (const ext of ['.tsx', '.ts', '.js']) {
|
||||
const indexPath = path.join(resolvedPath, `index${ext}`);
|
||||
if (fs.existsSync(indexPath)) {
|
||||
return indexPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Path doesn't exist yet, try adding extensions
|
||||
for (const ext of ['.tsx', '.ts', '.js']) {
|
||||
const withExt = resolvedPath + ext;
|
||||
if (fs.existsSync(withExt)) {
|
||||
return withExt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedPath;
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
featureAliasPlugin,
|
||||
react(),
|
||||
versionPlugin({ appName: 'Platform Content Tools' }),
|
||||
ignoreStyledDtsPlugin,
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
// @/ is handled by featureAliasPlugin
|
||||
'@features': path.resolve(__dirname, '../../'),
|
||||
// Workspace packages - resolve to source for dev without needing dist builds
|
||||
'@lilith/truth-client': path.resolve(__dirname, '../../truth-validation/client/typescript/src'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue