-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.worker.config.js
33 lines (30 loc) · 1.04 KB
/
vite.worker.config.js
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
// vite.config.js
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
const fs = require('fs')
const path = require('path')
const workersFolder = './src/web-workers'
const entries = fs.readdirSync(workersFolder).reduce((acc, file) => {
const withoutExt = path.basename(file, path.extname(file))
acc[withoutExt] = path.resolve(workersFolder, file)
return acc
}, {})
console.log(entries)
export default defineConfig({
plugins: [tsconfigPaths()],
build: {
// Specify the entry file for your web worker
rollupOptions: {
input: entries,
output: {
entryFileNames: `[name].js`, // Removes hash from JS files
chunkFileNames: `[name].js`, // Removes hash from chunk files
assetFileNames: `[name].[ext]`, // Removes hash from asset files like CSS
},
},
// Define output settings (optional)
outDir: './public', // The directory to output the built file
},
publicDir: './web', // The directory to find the entry file in
// Additional configurations for Vite
})