@pollora/vite-config 1.1.0 → 1.1.1
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/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +15 -2
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -54,3 +54,4 @@ export function layoutOf(settings: {
|
|
|
54
54
|
export function kebab(name: string): string;
|
|
55
55
|
export function blockEntries(root: string): Record<string, string>;
|
|
56
56
|
export function devServer(port: number): Record<string, unknown>;
|
|
57
|
+
export function usesWsOption(version?: string): boolean;
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { globSync } from 'glob';
|
|
4
|
+
import { version as viteVersion } from 'vite';
|
|
4
5
|
import laravel, { refreshPaths } from 'laravel-vite-plugin';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -70,6 +71,16 @@ function isDocker() {
|
|
|
70
71
|
return Boolean(process.env.IS_DOCKER || process.env.DOCKER_ENV || process.env.DDEV_PRIMARY_URL);
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Vite 8.3.1 moved the WebSocket options from `server.hmr` to `server.ws` and
|
|
76
|
+
* deprecated the old place; earlier versions only know `server.hmr`.
|
|
77
|
+
*/
|
|
78
|
+
export function usesWsOption(version = viteVersion) {
|
|
79
|
+
const [major, minor, patch] = version.split('.').map((part) => parseInt(part, 10));
|
|
80
|
+
|
|
81
|
+
return major > 8 || (major === 8 && (minor > 3 || (minor === 3 && patch >= 1)));
|
|
82
|
+
}
|
|
83
|
+
|
|
73
84
|
/**
|
|
74
85
|
* Dev server reachable from the site: inside DDEV or Docker it listens on every
|
|
75
86
|
* interface and announces the site's own host, elsewhere it serves localhost.
|
|
@@ -78,6 +89,8 @@ export function devServer(port) {
|
|
|
78
89
|
const url = baseUrl();
|
|
79
90
|
const isHttps = url.startsWith('https');
|
|
80
91
|
const hostname = new URL(url).hostname;
|
|
92
|
+
const socket = { protocol: isHttps ? 'wss' : 'ws', host: hostname };
|
|
93
|
+
const websocket = usesWsOption() ? { ws: socket } : { hmr: socket };
|
|
81
94
|
const common = {
|
|
82
95
|
port,
|
|
83
96
|
strictPort: true,
|
|
@@ -93,7 +106,7 @@ export function devServer(port) {
|
|
|
93
106
|
...common,
|
|
94
107
|
host: '0.0.0.0',
|
|
95
108
|
origin: `${url}:${port}`,
|
|
96
|
-
|
|
109
|
+
...websocket,
|
|
97
110
|
};
|
|
98
111
|
}
|
|
99
112
|
|
|
@@ -101,7 +114,7 @@ export function devServer(port) {
|
|
|
101
114
|
...common,
|
|
102
115
|
https: isHttps,
|
|
103
116
|
host: isHttps ? hostname : 'localhost',
|
|
104
|
-
|
|
117
|
+
...websocket,
|
|
105
118
|
};
|
|
106
119
|
}
|
|
107
120
|
|