-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.mjs
47 lines (44 loc) · 910 Bytes
/
vite.config.mjs
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
import fs from 'node:fs/promises'
import mkcert from 'vite-plugin-mkcert'
const files = await fs.readdir('./src/scripts', {})
const entryPoints = files.reduce((obj, file) => {
if (!file.endsWith('.js')) {
return obj
}
obj[file.replace('.js', '')] = `./src/scripts/${file}`
return obj
}, {})
export default {
root: './src',
base: 'https://localhost:3000/',
server: {
https: true,
hmr: {
host: 'localhost'
},
watch: ['./**/*.phtml']
},
plugins: [
mkcert(),
{
name: 'template-reload',
enforce: 'post',
handleHotUpdate({ file, server }) {
if (file.endsWith('.phtml')) {
server.ws.send({
type: 'full-reload',
path: '*'
})
}
}
}
],
build: {
manifest: true,
outDir: '../web/dist',
emptyOutDir: true,
rollupOptions: {
input: entryPoints
}
}
}