-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathvite.config.mts
More file actions
43 lines (40 loc) · 1.22 KB
/
vite.config.mts
File metadata and controls
43 lines (40 loc) · 1.22 KB
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
import { defineConfig, Plugin } from "vite";
import { viteStaticCopy } from "vite-plugin-static-copy";
import fs from "fs";
import path from "path";
function watchExternalPlugin(filePath: string): Plugin {
return {
name: "watch-external",
configureServer(server) {
const absPath = path.resolve(filePath);
server.watcher.add(absPath);
fs.watchFile(absPath, () => {
const module = server.moduleGraph.getModuleById(absPath);
if (module) server.moduleGraph.invalidateModule(module);
server.ws.send({ type: "full-reload", path: "*" });
});
},
};
}
export default defineConfig({
root: "src/web/www",
server: {
port: 8000,
host: true,
},
plugins: [
viteStaticCopy({
targets: [
{ src: "../../../_build/default/src/web/www/worker.js", dest: "" },
{
src: "../../../_build/default/src/web/www/bundled.js",
dest: "",
},
{ src: "../../../_build/default/src/web/www/hazel.js", dest: "" },
],
}),
watchExternalPlugin("./_build/default/src/web/www/worker.js"),
watchExternalPlugin("./_build/default/src/web/www/bundled.js"),
watchExternalPlugin("./_build/default/src/web/www/hazel.js"),
],
});