litestar-vite-plugin 0.1.5 → 0.1.8

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/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ const refreshPaths = [
40
40
  "**/*.py",
41
41
  "**/*.j2",
42
42
  "**/*.html.j2",
43
+ "**/*.html",
43
44
  "**/assets/**/*"
44
45
  ];
45
46
  function litestar(config) {
@@ -63,13 +64,14 @@ function resolveLitestarPlugin(pluginConfig) {
63
64
  userConfig = config;
64
65
  const ssr = !!userConfig.build?.ssr;
65
66
  const env = (0, import_vite.loadEnv)(mode, userConfig.envDir || process.cwd(), "");
66
- const assetUrl = env.ASSET_URL || pluginConfig.assetUrl;
67
+ const assetUrl = env.LITESTAR_ASSET_URL || pluginConfig.assetUrl;
67
68
  const serverConfig = command === "serve" ? resolveDevelopmentEnvironmentServerConfig(
68
69
  pluginConfig.detectTls
69
70
  ) ?? resolveEnvironmentServerConfig(env) : void 0;
70
71
  ensureCommandShouldRunInEnvironment(command, env);
71
72
  return {
72
73
  base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : pluginConfig.assetUrl),
74
+ root: pluginConfig.rootDirectory,
73
75
  publicDir: userConfig.publicDir ?? false,
74
76
  build: {
75
77
  manifest: userConfig.build?.manifest ?? !ssr,
@@ -241,6 +243,14 @@ function resolvePluginConfig(config) {
241
243
  );
242
244
  }
243
245
  }
246
+ if (typeof config.rootDirectory === "string") {
247
+ config.rootDirectory = config.rootDirectory.trim().replace(/^\/+/, "");
248
+ if (config.rootDirectory === "") {
249
+ throw new Error(
250
+ "litestar-vite-plugin: rootDirectory must be a subdirectory. E.g. '.'."
251
+ );
252
+ }
253
+ }
244
254
  if (typeof config.assetDirectory === "string") {
245
255
  config.assetDirectory = config.assetDirectory.trim().replace(/^\/+/, "");
246
256
  if (config.assetDirectory === "") {
@@ -249,11 +259,11 @@ function resolvePluginConfig(config) {
249
259
  );
250
260
  }
251
261
  }
252
- if (typeof config.buildDirectory === "string") {
253
- config.buildDirectory = config.buildDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
254
- if (config.buildDirectory === "") {
262
+ if (typeof config.bundleDirectory === "string") {
263
+ config.bundleDirectory = config.bundleDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
264
+ if (config.bundleDirectory === "") {
255
265
  throw new Error(
256
- "litestar-vite-plugin: buildDirectory must be a subdirectory. E.g. 'public'."
266
+ "litestar-vite-plugin: bundleDirectory must be a subdirectory. E.g. 'public'."
257
267
  );
258
268
  }
259
269
  }
@@ -265,14 +275,15 @@ function resolvePluginConfig(config) {
265
275
  }
266
276
  return {
267
277
  input: config.input,
278
+ rootDirectory: config.rootDirectory ?? process.cwd(),
268
279
  assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
269
280
  resourceDirectory: config.resourceDirectory ?? "/resources/",
270
281
  assetDirectory: config.assetDirectory ?? "assets",
271
- buildDirectory: config.buildDirectory || (config.buildDirectory ?? "public"),
282
+ bundleDirectory: config.bundleDirectory || (config.bundleDirectory ?? "public"),
272
283
  ssr: config.ssr ?? config.input,
273
- ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
284
+ ssrOutputDirectory: config.ssrOutputDirectory ?? import_path.default.join(config.resourceDirectory ?? "resources", "bootstrap/ssr"),
274
285
  refresh: config.refresh ?? false,
275
- hotFile: config.hotFile ?? import_path.default.join(config.assetDirectory ?? "hot"),
286
+ hotFile: config.hotFile ?? import_path.default.join(config.bundleDirectory ?? "public", "hot"),
276
287
  detectTls: config.detectTls ?? false,
277
288
  transformOnServe: config.transformOnServe ?? ((code) => code)
278
289
  };
@@ -290,7 +301,7 @@ function resolveOutDir(config, ssr) {
290
301
  if (ssr) {
291
302
  return config.ssrOutputDirectory;
292
303
  }
293
- return import_path.default.join(config.buildDirectory);
304
+ return import_path.default.join(config.bundleDirectory);
294
305
  }
295
306
  function resolveFullReloadConfig({
296
307
  refresh: config
package/dist/index.d.ts CHANGED
@@ -12,15 +12,21 @@ interface PluginConfig {
12
12
  */
13
13
  assetUrl?: string;
14
14
  /**
15
- * The public directory where all compiled assets should be written.
15
+ * The public directory where all compiled/bundled assets should be written.
16
16
  *
17
- * @default 'public'
17
+ * @default 'public/dist'
18
18
  */
19
- buildDirectory?: string;
19
+ bundleDirectory?: string;
20
20
  /**
21
- * The directory where all typescript/javascript source are written. This is used as the default "@" alias is pointed.
21
+ * The root directory for your project.
22
22
  *
23
- * @default 'resources'
23
+ * @default ''
24
+ */
25
+ rootDirectory?: string;
26
+ /**
27
+ * Litestar's public assets directory. These are the assets that Vite will serve when developing.
28
+ *
29
+ * @default '${rootDirectory}/resources'
24
30
  */
25
31
  resourceDirectory?: string;
26
32
  /**
@@ -32,7 +38,7 @@ interface PluginConfig {
32
38
  /**
33
39
  * The path to the "hot" file.
34
40
  *
35
- * @default `${buildDirectory}/hot`
41
+ * @default `${bundleDirectory}/hot`
36
42
  */
37
43
  hotFile?: string;
38
44
  /**
@@ -42,7 +48,7 @@ interface PluginConfig {
42
48
  /**
43
49
  * The directory where the SSR bundle should be written.
44
50
  *
45
- * @default '${buildDirectory}/bootstrap/ssr'
51
+ * @default '${bundleDirectory}/bootstrap/ssr'
46
52
  */
47
53
  ssrOutputDirectory?: string;
48
54
  /**
package/dist/index.mjs CHANGED
@@ -11,6 +11,7 @@ const refreshPaths = [
11
11
  "**/*.py",
12
12
  "**/*.j2",
13
13
  "**/*.html.j2",
14
+ "**/*.html",
14
15
  "**/assets/**/*"
15
16
  ];
16
17
  function litestar(config) {
@@ -34,13 +35,14 @@ function resolveLitestarPlugin(pluginConfig) {
34
35
  userConfig = config;
35
36
  const ssr = !!userConfig.build?.ssr;
36
37
  const env = loadEnv(mode, userConfig.envDir || process.cwd(), "");
37
- const assetUrl = env.ASSET_URL || pluginConfig.assetUrl;
38
+ const assetUrl = env.LITESTAR_ASSET_URL || pluginConfig.assetUrl;
38
39
  const serverConfig = command === "serve" ? resolveDevelopmentEnvironmentServerConfig(
39
40
  pluginConfig.detectTls
40
41
  ) ?? resolveEnvironmentServerConfig(env) : void 0;
41
42
  ensureCommandShouldRunInEnvironment(command, env);
42
43
  return {
43
44
  base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : pluginConfig.assetUrl),
45
+ root: pluginConfig.rootDirectory,
44
46
  publicDir: userConfig.publicDir ?? false,
45
47
  build: {
46
48
  manifest: userConfig.build?.manifest ?? !ssr,
@@ -212,6 +214,14 @@ function resolvePluginConfig(config) {
212
214
  );
213
215
  }
214
216
  }
217
+ if (typeof config.rootDirectory === "string") {
218
+ config.rootDirectory = config.rootDirectory.trim().replace(/^\/+/, "");
219
+ if (config.rootDirectory === "") {
220
+ throw new Error(
221
+ "litestar-vite-plugin: rootDirectory must be a subdirectory. E.g. '.'."
222
+ );
223
+ }
224
+ }
215
225
  if (typeof config.assetDirectory === "string") {
216
226
  config.assetDirectory = config.assetDirectory.trim().replace(/^\/+/, "");
217
227
  if (config.assetDirectory === "") {
@@ -220,11 +230,11 @@ function resolvePluginConfig(config) {
220
230
  );
221
231
  }
222
232
  }
223
- if (typeof config.buildDirectory === "string") {
224
- config.buildDirectory = config.buildDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
225
- if (config.buildDirectory === "") {
233
+ if (typeof config.bundleDirectory === "string") {
234
+ config.bundleDirectory = config.bundleDirectory.trim().replace(/^\/+/, "").replace(/\/+$/, "");
235
+ if (config.bundleDirectory === "") {
226
236
  throw new Error(
227
- "litestar-vite-plugin: buildDirectory must be a subdirectory. E.g. 'public'."
237
+ "litestar-vite-plugin: bundleDirectory must be a subdirectory. E.g. 'public'."
228
238
  );
229
239
  }
230
240
  }
@@ -236,14 +246,15 @@ function resolvePluginConfig(config) {
236
246
  }
237
247
  return {
238
248
  input: config.input,
249
+ rootDirectory: config.rootDirectory ?? process.cwd(),
239
250
  assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
240
251
  resourceDirectory: config.resourceDirectory ?? "/resources/",
241
252
  assetDirectory: config.assetDirectory ?? "assets",
242
- buildDirectory: config.buildDirectory || (config.buildDirectory ?? "public"),
253
+ bundleDirectory: config.bundleDirectory || (config.bundleDirectory ?? "public"),
243
254
  ssr: config.ssr ?? config.input,
244
- ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
255
+ ssrOutputDirectory: config.ssrOutputDirectory ?? path.join(config.resourceDirectory ?? "resources", "bootstrap/ssr"),
245
256
  refresh: config.refresh ?? false,
246
- hotFile: config.hotFile ?? path.join(config.assetDirectory ?? "hot"),
257
+ hotFile: config.hotFile ?? path.join(config.bundleDirectory ?? "public", "hot"),
247
258
  detectTls: config.detectTls ?? false,
248
259
  transformOnServe: config.transformOnServe ?? ((code) => code)
249
260
  };
@@ -261,7 +272,7 @@ function resolveOutDir(config, ssr) {
261
272
  if (ssr) {
262
273
  return config.ssrOutputDirectory;
263
274
  }
264
- return path.join(config.buildDirectory);
275
+ return path.join(config.bundleDirectory);
265
276
  }
266
277
  function resolveFullReloadConfig({
267
278
  refresh: config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litestar-vite-plugin",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "Litestar plugin for Vite.",
5
5
  "keywords": [
6
6
  "litestar",