litestar-vite-plugin 0.1.4 → 0.1.5
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 +13 -1
- package/dist/index.cjs +4 -11
- package/dist/index.d.ts +2 -8
- package/dist/index.mjs +4 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
# Litestar Vite Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Notice** This is experimental software
|
|
4
|
+
|
|
5
|
+
## What is this?
|
|
6
|
+
|
|
7
|
+
This is a library for Litestar and Vite that makes integration between the the two easier.
|
|
8
|
+
|
|
9
|
+
For details on usage, use the `litestar-vite` [plugin](https://github.com/cofin/litestar-vite)
|
|
10
|
+
|
|
11
|
+
## Credit
|
|
12
|
+
|
|
13
|
+
The team at Laravel have done an incredible job at making it easier to use common JS/TS frameworks with the framework.
|
|
14
|
+
|
|
15
|
+
This plugin is more than a little inspired by the worker here [Laravel's Vite Integration](https://github.com/laravel/vite-plugin)
|
package/dist/index.cjs
CHANGED
|
@@ -81,7 +81,7 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
81
81
|
},
|
|
82
82
|
server: {
|
|
83
83
|
origin: userConfig.server?.origin ?? "__litestar_vite_placeholder__",
|
|
84
|
-
...process.env.
|
|
84
|
+
...process.env.LITESTAR_VITE_ALLOW_REMOTE ? {
|
|
85
85
|
host: userConfig.server?.host ?? "0.0.0.0",
|
|
86
86
|
port: userConfig.server?.port ?? (env.VITE_PORT ? parseInt(env.VITE_PORT) : 5173),
|
|
87
87
|
strictPort: userConfig.server?.strictPort ?? true
|
|
@@ -233,12 +233,6 @@ function resolvePluginConfig(config) {
|
|
|
233
233
|
'litestar-vite-plugin: missing configuration for "input".'
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
|
-
if (typeof config.rootDirectory === "undefined") {
|
|
237
|
-
config.rootDirectory = "";
|
|
238
|
-
}
|
|
239
|
-
if (typeof config.rootDirectory === "string") {
|
|
240
|
-
config.rootDirectory = config.rootDirectory.trim().replace(/^\/+/, "");
|
|
241
|
-
}
|
|
242
236
|
if (typeof config.resourceDirectory === "string") {
|
|
243
237
|
config.resourceDirectory = config.resourceDirectory.trim().replace(/^\/+/, "");
|
|
244
238
|
if (config.resourceDirectory === "") {
|
|
@@ -272,9 +266,8 @@ function resolvePluginConfig(config) {
|
|
|
272
266
|
return {
|
|
273
267
|
input: config.input,
|
|
274
268
|
assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
assetDirectory: config.assetDirectory ?? "",
|
|
269
|
+
resourceDirectory: config.resourceDirectory ?? "/resources/",
|
|
270
|
+
assetDirectory: config.assetDirectory ?? "assets",
|
|
278
271
|
buildDirectory: config.buildDirectory || (config.buildDirectory ?? "public"),
|
|
279
272
|
ssr: config.ssr ?? config.input,
|
|
280
273
|
ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
|
|
@@ -327,7 +320,7 @@ function resolveDevServerUrl(address, config, userConfig) {
|
|
|
327
320
|
const protocol = clientProtocol ?? serverProtocol;
|
|
328
321
|
const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
|
|
329
322
|
const configHost = typeof config.server.host === "string" ? config.server.host : null;
|
|
330
|
-
const remoteHost = process.env.
|
|
323
|
+
const remoteHost = process.env.LITESTAR_VITE_ALLOW_REMOTE && !userConfig.server?.host ? "localhost" : null;
|
|
331
324
|
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
|
|
332
325
|
const host = configHmrHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
333
326
|
const configHmrClientPort = typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,12 +11,6 @@ interface PluginConfig {
|
|
|
11
11
|
* @default '/static/'
|
|
12
12
|
*/
|
|
13
13
|
assetUrl?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The base directory for all Vite source
|
|
16
|
-
*
|
|
17
|
-
* @default undefined
|
|
18
|
-
*/
|
|
19
|
-
rootDirectory?: string | undefined;
|
|
20
14
|
/**
|
|
21
15
|
* The public directory where all compiled assets should be written.
|
|
22
16
|
*
|
|
@@ -38,7 +32,7 @@ interface PluginConfig {
|
|
|
38
32
|
/**
|
|
39
33
|
* The path to the "hot" file.
|
|
40
34
|
*
|
|
41
|
-
* @default `${
|
|
35
|
+
* @default `${buildDirectory}/hot`
|
|
42
36
|
*/
|
|
43
37
|
hotFile?: string;
|
|
44
38
|
/**
|
|
@@ -48,7 +42,7 @@ interface PluginConfig {
|
|
|
48
42
|
/**
|
|
49
43
|
* The directory where the SSR bundle should be written.
|
|
50
44
|
*
|
|
51
|
-
* @default '${
|
|
45
|
+
* @default '${buildDirectory}/bootstrap/ssr'
|
|
52
46
|
*/
|
|
53
47
|
ssrOutputDirectory?: string;
|
|
54
48
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -52,7 +52,7 @@ function resolveLitestarPlugin(pluginConfig) {
|
|
|
52
52
|
},
|
|
53
53
|
server: {
|
|
54
54
|
origin: userConfig.server?.origin ?? "__litestar_vite_placeholder__",
|
|
55
|
-
...process.env.
|
|
55
|
+
...process.env.LITESTAR_VITE_ALLOW_REMOTE ? {
|
|
56
56
|
host: userConfig.server?.host ?? "0.0.0.0",
|
|
57
57
|
port: userConfig.server?.port ?? (env.VITE_PORT ? parseInt(env.VITE_PORT) : 5173),
|
|
58
58
|
strictPort: userConfig.server?.strictPort ?? true
|
|
@@ -204,12 +204,6 @@ function resolvePluginConfig(config) {
|
|
|
204
204
|
'litestar-vite-plugin: missing configuration for "input".'
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
|
-
if (typeof config.rootDirectory === "undefined") {
|
|
208
|
-
config.rootDirectory = "";
|
|
209
|
-
}
|
|
210
|
-
if (typeof config.rootDirectory === "string") {
|
|
211
|
-
config.rootDirectory = config.rootDirectory.trim().replace(/^\/+/, "");
|
|
212
|
-
}
|
|
213
207
|
if (typeof config.resourceDirectory === "string") {
|
|
214
208
|
config.resourceDirectory = config.resourceDirectory.trim().replace(/^\/+/, "");
|
|
215
209
|
if (config.resourceDirectory === "") {
|
|
@@ -243,9 +237,8 @@ function resolvePluginConfig(config) {
|
|
|
243
237
|
return {
|
|
244
238
|
input: config.input,
|
|
245
239
|
assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
assetDirectory: config.assetDirectory ?? "",
|
|
240
|
+
resourceDirectory: config.resourceDirectory ?? "/resources/",
|
|
241
|
+
assetDirectory: config.assetDirectory ?? "assets",
|
|
249
242
|
buildDirectory: config.buildDirectory || (config.buildDirectory ?? "public"),
|
|
250
243
|
ssr: config.ssr ?? config.input,
|
|
251
244
|
ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
|
|
@@ -298,7 +291,7 @@ function resolveDevServerUrl(address, config, userConfig) {
|
|
|
298
291
|
const protocol = clientProtocol ?? serverProtocol;
|
|
299
292
|
const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
|
|
300
293
|
const configHost = typeof config.server.host === "string" ? config.server.host : null;
|
|
301
|
-
const remoteHost = process.env.
|
|
294
|
+
const remoteHost = process.env.LITESTAR_VITE_ALLOW_REMOTE && !userConfig.server?.host ? "localhost" : null;
|
|
302
295
|
const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
|
|
303
296
|
const host = configHmrHost ?? remoteHost ?? configHost ?? serverAddress;
|
|
304
297
|
const configHmrClientPort = typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null;
|