-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
50 lines (47 loc) · 1.27 KB
/
vite.config.js
File metadata and controls
50 lines (47 loc) · 1.27 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
import { defineConfig } from 'vite'
import { copyFileSync, mkdirSync, readdirSync, statSync } from 'fs'
import { join } from 'path'
export default defineConfig({
root: './src',
base: './',
server: {
port: 3000,
open: true
},
build: {
outDir: '../dist',
assetsDir: 'assets',
rollupOptions: {
output: {
manualChunks: undefined
}
},
copyPublicDir: false // We'll handle copying manually
},
publicDir: './assets',
plugins: [
{
name: 'copy-assets',
writeBundle() {
// Create assets directory in dist
mkdirSync('dist/assets', { recursive: true })
// Automatically copy all files from src/assets to dist/assets
const assetsDir = 'src/assets'
try {
const files = readdirSync(assetsDir)
files.forEach(file => {
const srcPath = join(assetsDir, file)
const destPath = join('dist/assets', file)
// Only copy files (not directories)
if (statSync(srcPath).isFile()) {
copyFileSync(srcPath, destPath)
console.log(`Copied: ${file}`)
}
})
} catch (error) {
console.warn('Could not copy assets:', error.message)
}
}
}
]
})