forked from commaai/new-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
72 lines (71 loc) · 1.72 KB
/
vite.config.ts
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
// vite.config.js
import { defineConfig } from 'vite'
import solid from 'vite-plugin-solid'
import devtools from 'solid-devtools/vite'
import path from 'node:path'
import fs from 'node:fs'
export default defineConfig({
plugins: [
devtools(),
solid({
ssr: false,
}),
{
name: 'log-server-start',
configureServer(server) {
server.httpServer?.once('listening', () => {
const address = server.httpServer?.address()
if (typeof address === 'object' && address !== null) {
console.log(`Server listening on port ${address.port}`)
}
})
},
},
],
server: {
port: 3000,
},
build: {
target: 'esnext',
rollupOptions: {
input: {
main: 'index.html',
'service-worker': './src/service-worker.js',
},
output: {
entryFileNames: (chunkInfo) => {
return chunkInfo.name === 'service-worker'
? '[name].js'
: 'assets/[name]-[hash].js'
},
},
plugins: [
{
name: 'copy-pwa-assets',
generateBundle() {
const pwaAssetsDir = path.resolve(__dirname, 'pwa-assets')
if (fs.existsSync(pwaAssetsDir)) {
const files = fs.readdirSync(pwaAssetsDir)
for (const file of files) {
this.emitFile({
type: 'asset',
fileName: `pwa-assets/${file}`,
source: fs.readFileSync(path.resolve(pwaAssetsDir, file)),
})
}
}
},
},
],
},
},
resolve: {
alias: {
'~': '/src',
},
},
test: {
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
},
})