-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
45 lines (41 loc) · 1.15 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
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
// https://www.npmjs.com/package/vite-plugin-restart
import ViteRestart from "vite-plugin-restart";
// defaults, local DDEV (with ddev-router)
const port = 5173;
const origin = `${process.env.DDEV_PRIMARY_URL}:${port}`;
// for debugging:
// console.log(process.env);
console.log("Local DDEV detected", {
port,
origin,
});
export default defineConfig(({ command }) => ({
// 'vite' is always command = 'serve', other command is 'build'
base: command === "serve" ? "" : "/dist/",
build: {
manifest: true,
outDir: "web/dist/",
rollupOptions: {
input: {
app: "./src/js/app.ts",
},
},
},
// adjustments for ddev:
server: {
// respond to all network requests:
host: "0.0.0.0",
port: port,
strictPort: true,
// origin is important, see https://nystudio107.com/docs/vite/#vite-processed-assets
origin: origin,
},
plugins: [
tsconfigPaths(),
ViteRestart({
restart: ["./templates/**/*"],
}),
],
}));