-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
49 lines (42 loc) · 1.12 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
37
38
39
40
41
42
43
44
45
46
47
48
49
import { globSync } from 'glob';
import { resolve } from 'path';
import { defineConfig } from 'vite';
import kirby from 'vite-plugin-kirby';
// set port and origin for server config
const port = 5173;
const origin = `${process.env.DDEV_PRIMARY_URL}:${port}`;
// build directory
const outDir = 'build';
const assetsDir = 'assets';
// find all css and js files from the assets directory
const input = [...globSync('assets/**/*.{css,js}')].map(
(path) => resolve(process.cwd(), path)
);
// noinspection JSCheckFunctionSignatures,JSUnusedGlobalSymbols
export default defineConfig(({ mode }) => ({
base: mode === 'development' ? '/' : `/${outDir}`,
build: {
outDir: outDir,
assetsDir: assetsDir,
rollupOptions: {
input: input
}
},
// adjust vite's dev server for ddev
server: {
// respond to all network requests:
host: '0.0.0.0',
port: port,
strictPort: true,
// defines the origin of the generated asset URLs during development
origin: origin
},
plugins: [
kirby({
watch: [
'site/(templates|snippets)/**/*.php',
'content/**/*',
]
})
]
}));