@theholocron/vite-config 4.1.0 → 5.0.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/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Vite Config
2
+
3
+ A [Vite configuration](https://vite.dev/config/) with presets for libraries, React apps, and Node.js tools within the Galaxy.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install --save-dev @theholocron/vite-config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Pick the preset that matches your project type. All presets accept an `overrides` object that is deep-merged last via `mergeConfig`.
14
+
15
+ ### Publishable library
16
+
17
+ Outputs ESM only; externalises `react` and `react-dom` by default.
18
+
19
+ ```javascript
20
+ import { defineConfig } from "vite";
21
+ import { library } from "@theholocron/vite-config/library";
22
+
23
+ export default defineConfig(
24
+ library({ entry: "src/index.ts", name: "MyLib" })
25
+ );
26
+ ```
27
+
28
+ ### React single-page application
29
+
30
+ Requires `@vitejs/plugin-react` as a peer dependency. Returns a `Promise` because the plugin is loaded dynamically.
31
+
32
+ ```javascript
33
+ import { defineConfig } from "vite";
34
+ import { reactApp } from "@theholocron/vite-config/react-app";
35
+
36
+ export default defineConfig(await reactApp());
37
+ ```
38
+
39
+ Pass `vite-tsconfig-paths` via `overrides.plugins` to enable tsconfig path aliases:
40
+
41
+ ```javascript
42
+ import { defineConfig } from "vite";
43
+ import tsconfigPaths from "vite-tsconfig-paths";
44
+ import { reactApp } from "@theholocron/vite-config/react-app";
45
+
46
+ export default defineConfig(await reactApp({ plugins: [tsconfigPaths()] }));
47
+ ```
48
+
49
+ ### Node.js CLI tool or server app
50
+
51
+ Targets Node 22; outputs a single ESM bundle with no browser polyfills.
52
+
53
+ ```javascript
54
+ import { defineConfig } from "vite";
55
+ import { nodeApp } from "@theholocron/vite-config/node-app";
56
+
57
+ export default defineConfig(nodeApp({ entry: "src/index.ts" }));
58
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/vite-config",
3
- "version": "4.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "Vite configuration presets for libraries, React apps, and Node tools within the Galaxy.",
5
5
  "homepage": "https://github.com/theholocron/configs/tree/main/packages/vite-config#readme",
6
6
  "bugs": "https://github.com/theholocron/configs/issues",
@@ -1,5 +1,4 @@
1
1
  import { mergeConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
2
 
4
3
  /**
5
4
  * Vite preset for React single-page applications.
@@ -7,9 +6,11 @@ import react from "@vitejs/plugin-react";
7
6
  * via options.plugins if tsconfig path aliases are needed.
8
7
  *
9
8
  * @param {import('vite').UserConfig} [overrides={}]
10
- * @returns {import('vite').UserConfig}
9
+ * @returns {Promise<import('vite').UserConfig>}
11
10
  */
12
- export function reactApp(overrides = {}) {
11
+ export async function reactApp(overrides = {}) {
12
+ const { default: react } = await import("@vitejs/plugin-react");
13
+
13
14
  return mergeConfig(
14
15
  {
15
16
  plugins: [react()],