forked from Orillusion/orillusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
36 lines (35 loc) · 1.09 KB
/
vite.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
34
35
36
// vite.config.js
import { defineConfig } from 'vite'
import { readFile, writeFile } from 'fs/promises'
import {resolve} from 'path'
module.exports = defineConfig({
server: {
port: 3000,
// hmr: false // open this line if no auto hot-reload required
},
resolve: {
alias: {
'@orillusion/core': resolve(__dirname, './src/index.ts'),
'@orillusion': resolve(__dirname, './src/libs')
},
mainFields: ['module:dev', 'module']
},
plugins: [{
name: 'autoIndex',
configureServer(server) {
server.ws.on('autoIndex', async (data) => {
let content = await readFile(resolve(__dirname, './src/index.ts'), 'utf-8')
if(data.content !== content)
writeFile(resolve(__dirname, './src/index.ts'), data.content)
})
}
}],
build: {
lib: {
entry: resolve(__dirname, './src/index.ts'),
name: 'Orillusion',
fileName: (format) => `orillusion.${format}.js`
},
// minify: 'terser'
}
})