@devtime-ltd/vite-plugin-slate 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,11 +48,27 @@ server: {
48
48
  cors: true, // allow the cross-origin app host to load assets
49
49
  allowedHosts: ["vite.app--feat.test"], // accept the proxied Host header
50
50
  hmr: { host: "vite.app--feat.test", protocol: "wss", clientPort: 443 },
51
+ watch: { usePolling: false }, // native fs events; see below
51
52
  }
52
53
  ```
53
54
 
54
- These are merged into your existing `server` config, so options like
55
- `server.watch.usePolling` are preserved.
55
+ These are merged into your existing `server` config.
56
+
57
+ ### Filesystem watching
58
+
59
+ slate's runtime (OrbStack) forwards native filesystem events into the container,
60
+ so Vite doesn't need to poll the worktree — and polling burns a full CPU core per
61
+ workspace, which adds up fast when you run several projects at once. The plugin
62
+ therefore disables polling under slate, **overriding** a `server.watch.usePolling: true`
63
+ in your own config (which is typically a Docker Desktop workaround and unnecessary
64
+ here).
65
+
66
+ If your Docker runtime doesn't forward fs events and HMR stops noticing changes,
67
+ opt back in:
68
+
69
+ ```js
70
+ slate({ poll: true })
71
+ ```
56
72
 
57
73
  ## License
58
74
 
package/index.d.ts CHANGED
@@ -1,7 +1,17 @@
1
1
  import type { Plugin } from "vite";
2
2
 
3
+ export interface SlateOptions {
4
+ /**
5
+ * Force filesystem polling (`server.watch.usePolling`). Defaults to `false`:
6
+ * slate's runtime forwards native fs events into the container, so polling
7
+ * wastes a CPU core per workspace. Set `true` only if your Docker runtime
8
+ * doesn't forward events and HMR misses changes.
9
+ */
10
+ poll?: boolean;
11
+ }
12
+
3
13
  /**
4
14
  * Wires the Vite dev server to slate's HTTPS proxy using the VITE_DEV_SERVER_URL
5
15
  * env var that slate sets inside a workspace. No-op when that var is unset.
6
16
  */
7
- export default function slate(): Plugin;
17
+ export default function slate(options?: SlateOptions): Plugin;
package/index.js CHANGED
@@ -4,7 +4,14 @@
4
4
  // and rejects the proxied Host header with a 403. This points Vite at the proxy
5
5
  // URL and allows the host. No-op when the var is unset, so a plain `npm run dev`
6
6
  // outside slate is unaffected.
7
- export default function slate() {
7
+ //
8
+ // Options:
9
+ // poll Force filesystem polling (server.watch.usePolling). Default false:
10
+ // slate's runtime (OrbStack) forwards native fs events into the
11
+ // container, so polling just burns a CPU core per workspace. Set true
12
+ // only if your Docker runtime doesn't forward events and HMR misses
13
+ // changes.
14
+ export default function slate(options = {}) {
8
15
  return {
9
16
  name: "vite-plugin-slate",
10
17
  apply: "serve",
@@ -26,6 +33,9 @@ export default function slate() {
26
33
  protocol: secure ? "wss" : "ws",
27
34
  clientPort,
28
35
  },
36
+ watch: {
37
+ usePolling: options.poll === true,
38
+ },
29
39
  },
30
40
  };
31
41
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtime-ltd/vite-plugin-slate",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Vite plugin that wires the dev server to slate's HTTPS proxy.",
5
5
  "type": "module",
6
6
  "main": "index.js",