-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
151 lines (138 loc) · 6.29 KB
/
vite.config.ts
File metadata and controls
151 lines (138 loc) · 6.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { saveContentPlugin } from './vite-plugin-save-content';
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from 'fs';
// Plugin to copy assets from src/assets to public/assets during build
function copyAssetsPlugin() {
return {
name: 'copy-assets',
buildStart() {
const srcAssets = path.resolve(__dirname, 'src/assets');
const publicAssets = path.resolve(__dirname, 'public/assets');
if (existsSync(srcAssets)) {
if (!existsSync(publicAssets)) {
mkdirSync(publicAssets, { recursive: true });
}
const copyRecursive = (src: string, dest: string) => {
const entries = readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
if (!existsSync(destPath)) {
mkdirSync(destPath, { recursive: true });
}
copyRecursive(srcPath, destPath);
} else {
copyFileSync(srcPath, destPath);
}
}
};
try {
copyRecursive(srcAssets, publicAssets);
console.log('✓ Assets copied to public/assets');
} catch (error) {
console.warn('Warning: Could not copy assets:', error);
}
}
},
};
}
// Plugin to ensure public/assets images are copied to build/assets
function copyPublicAssetsPlugin() {
return {
name: 'copy-public-assets',
writeBundle() {
const publicAssets = path.resolve(__dirname, 'public/assets');
const buildAssets = path.resolve(__dirname, 'build/assets');
if (existsSync(publicAssets)) {
if (!existsSync(buildAssets)) {
mkdirSync(buildAssets, { recursive: true });
}
const copyRecursive = (src: string, dest: string) => {
const entries = readdirSync(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
// Skip if it's a JS or CSS file (already handled by Vite)
if (entry.isFile() && (entry.name.endsWith('.js') || entry.name.endsWith('.css'))) {
continue;
}
if (entry.isDirectory()) {
if (!existsSync(destPath)) {
mkdirSync(destPath, { recursive: true });
}
copyRecursive(srcPath, destPath);
} else {
copyFileSync(srcPath, destPath);
}
}
};
try {
copyRecursive(publicAssets, buildAssets);
console.log('✓ Public assets copied to build/assets');
} catch (error) {
console.warn('Warning: Could not copy public assets:', error);
}
}
},
};
}
export default defineConfig({
plugins: [react(), saveContentPlugin(), copyAssetsPlugin(), copyPublicAssetsPlugin()],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
alias: {
'vaul@1.1.2': 'vaul',
'sonner@2.0.3': 'sonner',
'recharts@2.15.2': 'recharts',
'react-resizable-panels@2.1.7': 'react-resizable-panels',
'react-hook-form@7.55.0': 'react-hook-form',
'react-day-picker@8.10.1': 'react-day-picker',
'next-themes@0.4.6': 'next-themes',
'lucide-react@0.487.0': 'lucide-react',
'input-otp@1.4.2': 'input-otp',
'figma:asset/eb2091338e5a526e6c52dbe7891867bad0365a67.png': path.resolve(__dirname, './src/assets/eb2091338e5a526e6c52dbe7891867bad0365a67.png'),
'figma:asset/cc03d6b7b9b6c0b127b5885a899b19b8d05b9f15.png': path.resolve(__dirname, './src/assets/cc03d6b7b9b6c0b127b5885a899b19b8d05b9f15.png'),
'embla-carousel-react@8.6.0': 'embla-carousel-react',
'cmdk@1.1.1': 'cmdk',
'class-variance-authority@0.7.1': 'class-variance-authority',
'@radix-ui/react-tooltip@1.1.8': '@radix-ui/react-tooltip',
'@radix-ui/react-toggle@1.1.2': '@radix-ui/react-toggle',
'@radix-ui/react-toggle-group@1.1.2': '@radix-ui/react-toggle-group',
'@radix-ui/react-tabs@1.1.3': '@radix-ui/react-tabs',
'@radix-ui/react-switch@1.1.3': '@radix-ui/react-switch',
'@radix-ui/react-slot@1.1.2': '@radix-ui/react-slot',
'@radix-ui/react-slider@1.2.3': '@radix-ui/react-slider',
'@radix-ui/react-separator@1.1.2': '@radix-ui/react-separator',
'@radix-ui/react-select@2.1.6': '@radix-ui/react-select',
'@radix-ui/react-scroll-area@1.2.3': '@radix-ui/react-scroll-area',
'@radix-ui/react-radio-group@1.2.3': '@radix-ui/react-radio-group',
'@radix-ui/react-progress@1.1.2': '@radix-ui/react-progress',
'@radix-ui/react-popover@1.1.6': '@radix-ui/react-popover',
'@radix-ui/react-navigation-menu@1.2.5': '@radix-ui/react-navigation-menu',
'@radix-ui/react-menubar@1.1.6': '@radix-ui/react-menubar',
'@radix-ui/react-label@2.1.2': '@radix-ui/react-label',
'@radix-ui/react-hover-card@1.1.6': '@radix-ui/react-hover-card',
'@radix-ui/react-dropdown-menu@2.1.6': '@radix-ui/react-dropdown-menu',
'@radix-ui/react-dialog@1.1.6': '@radix-ui/react-dialog',
'@radix-ui/react-context-menu@2.2.6': '@radix-ui/react-context-menu',
'@radix-ui/react-collapsible@1.1.3': '@radix-ui/react-collapsible',
'@radix-ui/react-checkbox@1.1.4': '@radix-ui/react-checkbox',
'@radix-ui/react-avatar@1.1.3': '@radix-ui/react-avatar',
'@radix-ui/react-aspect-ratio@1.1.2': '@radix-ui/react-aspect-ratio',
'@radix-ui/react-alert-dialog@1.1.6': '@radix-ui/react-alert-dialog',
'@radix-ui/react-accordion@1.2.3': '@radix-ui/react-accordion',
'@': path.resolve(__dirname, './src'),
},
},
build: {
target: 'esnext',
outDir: 'build',
},
server: {
port: 3000,
open: true,
},
});