blob: 2d99b637d47490b2d91c9e4155c1996c22d9ac6f [file] [log] [blame]
Pokey Rulee2a8c2f2025-04-23 15:09:25 +01001import { dirname, resolve } from "node:path";
2import { fileURLToPath } from "node:url";
3import { hmrPlugin, presets } from "vite-plugin-web-components-hmr";
4import { defineConfig } from "vite";
5
6const __dirname = dirname(fileURLToPath(import.meta.url));
7
8export default defineConfig({
9 plugins: [
10 hmrPlugin({
11 include: ["./src/**/*.ts"],
12 presets: [presets.lit],
13 }),
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000014 // Custom plugin for handling the root path redirect
15 {
16 name: "configure-server",
17 configureServer(server) {
18 server.middlewares.use((req, res, next) => {
19 if (req.url === "/") {
20 res.writeHead(302, {
21 Location: "/src/web-components/demo/index.html",
22 });
23 res.end();
24 return;
25 }
26 next();
27 });
28 },
29 },
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010030 ],
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000031 server: {
32 // Define a middleware to handle the root path redirects
33 middlewareMode: false,
34 fs: {
35 // Allow serving files from these directories
36 allow: ["/app/webui"],
37 },
38 },
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010039});