blob: 9765931821b5a94d13761b103cd66d3ac5f8bcee [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
Pokey Rulec575fd72025-05-06 15:46:38 +010036 allow: ["."],
Philip Zeyliger16fa8b42025-05-02 04:28:16 +000037 },
38 },
Pokey Rulee2a8c2f2025-04-23 15:09:25 +010039});