litestar-vite-plugin 0.1.7 → 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
@@ -71,6 +71,7 @@ function resolveLitestarPlugin(pluginConfig) {
71
71
  ensureCommandShouldRunInEnvironment(command, env);
72
72
  return {
73
73
  base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : pluginConfig.assetUrl),
74
+ root: pluginConfig.rootDirectory,
74
75
  publicDir: userConfig.publicDir ?? false,
75
76
  build: {
76
77
  manifest: userConfig.build?.manifest ?? !ssr,
@@ -242,6 +243,14 @@ function resolvePluginConfig(config) {
242
243
  );
243
244
  }
244
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
+ }
245
254
  if (typeof config.assetDirectory === "string") {
246
255
  config.assetDirectory = config.assetDirectory.trim().replace(/^\/+/, "");
247
256
  if (config.assetDirectory === "") {
@@ -266,14 +275,15 @@ function resolvePluginConfig(config) {
266
275
  }
267
276
  return {
268
277
  input: config.input,
278
+ rootDirectory: config.rootDirectory ?? process.cwd(),
269
279
  assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
270
280
  resourceDirectory: config.resourceDirectory ?? "/resources/",
271
281
  assetDirectory: config.assetDirectory ?? "assets",
272
282
  bundleDirectory: config.bundleDirectory || (config.bundleDirectory ?? "public"),
273
283
  ssr: config.ssr ?? config.input,
274
- ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
284
+ ssrOutputDirectory: config.ssrOutputDirectory ?? import_path.default.join(config.resourceDirectory ?? "resources", "bootstrap/ssr"),
275
285
  refresh: config.refresh ?? false,
276
- hotFile: config.hotFile ?? import_path.default.join(config.assetDirectory ?? "hot"),
286
+ hotFile: config.hotFile ?? import_path.default.join(config.bundleDirectory ?? "public", "hot"),
277
287
  detectTls: config.detectTls ?? false,
278
288
  transformOnServe: config.transformOnServe ?? ((code) => code)
279
289
  };
package/dist/index.d.ts CHANGED
@@ -14,13 +14,19 @@ interface PluginConfig {
14
14
  /**
15
15
  * The public directory where all compiled/bundled assets should be written.
16
16
  *
17
- * @default 'public'
17
+ * @default 'public/dist'
18
18
  */
19
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
  /**
package/dist/index.mjs CHANGED
@@ -42,6 +42,7 @@ function resolveLitestarPlugin(pluginConfig) {
42
42
  ensureCommandShouldRunInEnvironment(command, env);
43
43
  return {
44
44
  base: userConfig.base ?? (command === "build" ? resolveBase(pluginConfig, assetUrl) : pluginConfig.assetUrl),
45
+ root: pluginConfig.rootDirectory,
45
46
  publicDir: userConfig.publicDir ?? false,
46
47
  build: {
47
48
  manifest: userConfig.build?.manifest ?? !ssr,
@@ -213,6 +214,14 @@ function resolvePluginConfig(config) {
213
214
  );
214
215
  }
215
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
+ }
216
225
  if (typeof config.assetDirectory === "string") {
217
226
  config.assetDirectory = config.assetDirectory.trim().replace(/^\/+/, "");
218
227
  if (config.assetDirectory === "") {
@@ -237,14 +246,15 @@ function resolvePluginConfig(config) {
237
246
  }
238
247
  return {
239
248
  input: config.input,
249
+ rootDirectory: config.rootDirectory ?? process.cwd(),
240
250
  assetUrl: config.assetUrl || (config.assetUrl ?? "static"),
241
251
  resourceDirectory: config.resourceDirectory ?? "/resources/",
242
252
  assetDirectory: config.assetDirectory ?? "assets",
243
253
  bundleDirectory: config.bundleDirectory || (config.bundleDirectory ?? "public"),
244
254
  ssr: config.ssr ?? config.input,
245
- ssrOutputDirectory: config.ssrOutputDirectory ?? "bootstrap/ssr",
255
+ ssrOutputDirectory: config.ssrOutputDirectory ?? path.join(config.resourceDirectory ?? "resources", "bootstrap/ssr"),
246
256
  refresh: config.refresh ?? false,
247
- hotFile: config.hotFile ?? path.join(config.assetDirectory ?? "hot"),
257
+ hotFile: config.hotFile ?? path.join(config.bundleDirectory ?? "public", "hot"),
248
258
  detectTls: config.detectTls ?? false,
249
259
  transformOnServe: config.transformOnServe ?? ((code) => code)
250
260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litestar-vite-plugin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Litestar plugin for Vite.",
5
5
  "keywords": [
6
6
  "litestar",