@devtime-ltd/vite-plugin-slate 0.1.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/LICENSE +21 -0
- package/README.md +59 -0
- package/index.d.ts +7 -0
- package/index.js +33 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Devtime Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @devtime-ltd/vite-plugin-slate
|
|
2
|
+
|
|
3
|
+
A Vite plugin that makes the dev server work behind [slate](https://github.com/devtime-ltd/slate)'s HTTPS proxy.
|
|
4
|
+
|
|
5
|
+
Inside a slate workspace, Vite is reached over a proxied HTTPS subdomain (e.g.
|
|
6
|
+
`https://vite.app--feat.test`) rather than `http://0.0.0.0:5173`. Without this,
|
|
7
|
+
the page (served over HTTPS) requests assets over plain HTTP — browsers block the
|
|
8
|
+
mixed content — and Vite 5+ rejects the proxied `Host` header with a 403.
|
|
9
|
+
|
|
10
|
+
This plugin reads the `VITE_DEV_SERVER_URL` env var that slate sets in the
|
|
11
|
+
workspace and configures Vite's `server.origin`, `allowedHosts`, `cors`, and
|
|
12
|
+
`hmr` accordingly, so assets and HMR load over HTTPS.
|
|
13
|
+
|
|
14
|
+
It is a **no-op when `VITE_DEV_SERVER_URL` is unset**, so running `npm run dev`
|
|
15
|
+
outside slate behaves exactly as before.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm i -D @devtime-ltd/vite-plugin-slate
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
// vite.config.js
|
|
27
|
+
import { defineConfig } from "vite";
|
|
28
|
+
import laravel from "laravel-vite-plugin";
|
|
29
|
+
import slate from "@devtime-ltd/vite-plugin-slate";
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
plugins: [
|
|
33
|
+
laravel({ /* ... */ }),
|
|
34
|
+
slate(),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
That's it — no configuration. The plugin only applies during `vite serve` (dev).
|
|
40
|
+
|
|
41
|
+
## What it sets
|
|
42
|
+
|
|
43
|
+
When `VITE_DEV_SERVER_URL=https://vite.app--feat.test`:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
server: {
|
|
47
|
+
origin: "https://vite.app--feat.test", // dev-server URL written to the hot file
|
|
48
|
+
cors: true, // allow the cross-origin app host to load assets
|
|
49
|
+
allowedHosts: ["vite.app--feat.test"], // accept the proxied Host header
|
|
50
|
+
hmr: { host: "vite.app--feat.test", protocol: "wss", clientPort: 443 },
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
These are merged into your existing `server` config, so options like
|
|
55
|
+
`server.watch.usePolling` are preserved.
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// When a workspace runs under slate, VITE_DEV_SERVER_URL holds the proxied HTTPS
|
|
2
|
+
// URL for the Vite dev server (e.g. https://vite.app--feat.test). Vite otherwise
|
|
3
|
+
// advertises http://0.0.0.0:5173 in its hot file (mixed-content on an HTTPS page)
|
|
4
|
+
// and rejects the proxied Host header with a 403. This points Vite at the proxy
|
|
5
|
+
// URL and allows the host. No-op when the var is unset, so a plain `npm run dev`
|
|
6
|
+
// outside slate is unaffected.
|
|
7
|
+
export default function slate() {
|
|
8
|
+
return {
|
|
9
|
+
name: "vite-plugin-slate",
|
|
10
|
+
apply: "serve",
|
|
11
|
+
config() {
|
|
12
|
+
const devServerUrl = process.env.VITE_DEV_SERVER_URL;
|
|
13
|
+
if (!devServerUrl) return {};
|
|
14
|
+
|
|
15
|
+
const url = new URL(devServerUrl);
|
|
16
|
+
const secure = url.protocol === "https:";
|
|
17
|
+
const clientPort = Number(url.port) || (secure ? 443 : 80);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
server: {
|
|
21
|
+
origin: devServerUrl,
|
|
22
|
+
cors: true,
|
|
23
|
+
allowedHosts: [url.hostname],
|
|
24
|
+
hmr: {
|
|
25
|
+
host: url.hostname,
|
|
26
|
+
protocol: secure ? "wss" : "ws",
|
|
27
|
+
clientPort,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@devtime-ltd/vite-plugin-slate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vite plugin that wires the dev server to slate's HTTPS proxy.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"module": "index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"index.js",
|
|
17
|
+
"index.d.ts",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "node --test"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"vite",
|
|
27
|
+
"vite-plugin",
|
|
28
|
+
"slate",
|
|
29
|
+
"laravel",
|
|
30
|
+
"https",
|
|
31
|
+
"proxy",
|
|
32
|
+
"hmr"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/devtime-ltd/slate.git",
|
|
37
|
+
"directory": "vite-plugin-slate"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/devtime-ltd/slate/tree/main/vite-plugin-slate#readme",
|
|
40
|
+
"bugs": "https://github.com/devtime-ltd/slate/issues",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"vite": ">=5"
|
|
44
|
+
}
|
|
45
|
+
}
|