@gusnips/vite 0.8.24 → 0.8.26

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 CHANGED
@@ -163,7 +163,8 @@ Writes `assets/theme-<hash>.js` and one `<script src>` at the end of `<head>`, s
163
163
  painted in the reader's theme before anything else runs. The file is the source of `startTheme`
164
164
  from `@gusnips/react/theme`, so the script before paint and the controller the app uses are
165
165
  the same function. It is a file rather than an inline script so a `script-src 'self'` policy
166
- lets it run. Pass it the same options you pass `createTheme`; see that package's README.
166
+ lets it run. Pass it the same options you pass `createTheme`; see that package's README. On
167
+ [the preset](#the-vite-preset), put it in `plugins`.
167
168
 
168
169
  `themeScript` is built on `prePaintScript`, which takes any script that has to run before the
169
170
  page shows. `@gusnips/locale`'s `localeGateScript` is the other one:
@@ -258,10 +259,21 @@ top-level key, so that is refused.
258
259
 
259
260
  ```ts
260
261
  import { webPreset } from "@gusnips/vite/preset";
262
+ import { defineConfig } from "vite";
261
263
 
262
- export default defineConfig(webPreset({/* … */}));
264
+ export default defineConfig(webPreset({ root: import.meta.dirname, port: 5173 }));
263
265
  ```
264
266
 
265
- Its own subpath too, since it pulls in the React and Tailwind plugins.
267
+ It adds the React and Tailwind plugins, points `@` at `src`, and runs `vite preview` on the port
268
+ minus 1000. `root` is required: it is the folder that holds `index.html`. Its own subpath too,
269
+ since it pulls in those two plugins.
270
+
271
+ Pass more plugins in `plugins`. They run after the preset's own:
272
+
273
+ ```ts
274
+ export default defineConfig(
275
+ webPreset({ root: import.meta.dirname, port: 5173, plugins: [themeScript(THEME)] }),
276
+ );
277
+ ```
266
278
 
267
279
  MIT · part of [frontkit](https://github.com/gusnips/frontkit)
package/dist/preset.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Plugin, UserConfig } from "vite";
1
+ import type { Plugin, PluginOption, UserConfig } from "vite";
2
2
  /**
3
3
  * Substitute `%NAME%` placeholders in `index.html`.
4
4
  *
@@ -32,6 +32,8 @@ export interface WebPresetOptions {
32
32
  * Vite-only semantics in them (aliases, `?raw`, `define`) if that behaviour ever changed.
33
33
  */
34
34
  ssrScope?: string;
35
+ /** More plugins, after the preset's own: `[themeScript(THEME)]`. */
36
+ plugins?: PluginOption[];
35
37
  }
36
- export declare function webPreset({ root, port, previewPort, placeholders, ssrScope, }: WebPresetOptions): UserConfig;
38
+ export declare function webPreset({ root, port, previewPort, placeholders, ssrScope, plugins, }: WebPresetOptions): UserConfig;
37
39
  //# sourceMappingURL=preset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAWjF;AAED,MAAM,WAAW,gBAAgB;IAC/B;+DAC2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb;qCACiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;kCAC8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,QAAQ,GACT,EAAE,gBAAgB,GAAG,UAAU,CAa/B"}
1
+ {"version":3,"file":"preset.d.ts","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE7D;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAWjF;AAED,MAAM,WAAW,gBAAgB;IAC/B;+DAC2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb;qCACiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;kCAC8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,OAAY,GACb,EAAE,gBAAgB,GAAG,UAAU,CAkB/B"}
package/dist/preset.js CHANGED
@@ -28,10 +28,15 @@ export function htmlPlaceholders(values) {
28
28
  },
29
29
  };
30
30
  }
31
- export function webPreset({ root, port, previewPort, placeholders, ssrScope, }) {
31
+ export function webPreset({ root, port, previewPort, placeholders, ssrScope, plugins = [], }) {
32
32
  const preview = previewPort ?? (port === undefined ? undefined : port - 1000);
33
33
  return {
34
- plugins: [react(), tailwindcss(), ...(placeholders ? [htmlPlaceholders(placeholders)] : [])],
34
+ plugins: [
35
+ react(),
36
+ tailwindcss(),
37
+ ...(placeholders ? [htmlPlaceholders(placeholders)] : []),
38
+ ...plugins,
39
+ ],
35
40
  resolve: {
36
41
  alias: { "@": path.resolve(root, "src") },
37
42
  },
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../src/preset.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAA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,EAAE;YACP,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;SAC1C;QACD,GAAG,CAAC,QAAQ,IAAI;YACd,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;SAC1F,CAAC;QACF,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;QAC/C,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC;KAC7D,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gusnips/vite",
3
- "version": "0.8.24",
3
+ "version": "0.8.26",
4
4
  "description": "The build-time half of a prerendered Vite SPA: head baking, sitemap, robots, the prerender driver, a shared vite preset, and the translation catalog check.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -69,7 +69,7 @@
69
69
  "release:major": "bun pm version major && bun publish --access public"
70
70
  },
71
71
  "dependencies": {
72
- "@gusnips/react": "0.9.15"
72
+ "@gusnips/react": "0.9.17"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "@tailwindcss/vite": "^4",
package/src/preset.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  import tailwindcss from "@tailwindcss/vite";
9
9
  import react from "@vitejs/plugin-react";
10
10
  import path from "node:path";
11
- import type { Plugin, UserConfig } from "vite";
11
+ import type { Plugin, PluginOption, UserConfig } from "vite";
12
12
 
13
13
  /**
14
14
  * Substitute `%NAME%` placeholders in `index.html`.
@@ -55,6 +55,8 @@ export interface WebPresetOptions {
55
55
  * Vite-only semantics in them (aliases, `?raw`, `define`) if that behaviour ever changed.
56
56
  */
57
57
  ssrScope?: string;
58
+ /** More plugins, after the preset's own: `[themeScript(THEME)]`. */
59
+ plugins?: PluginOption[];
58
60
  }
59
61
 
60
62
  export function webPreset({
@@ -63,10 +65,16 @@ export function webPreset({
63
65
  previewPort,
64
66
  placeholders,
65
67
  ssrScope,
68
+ plugins = [],
66
69
  }: WebPresetOptions): UserConfig {
67
70
  const preview = previewPort ?? (port === undefined ? undefined : port - 1000);
68
71
  return {
69
- plugins: [react(), tailwindcss(), ...(placeholders ? [htmlPlaceholders(placeholders)] : [])],
72
+ plugins: [
73
+ react(),
74
+ tailwindcss(),
75
+ ...(placeholders ? [htmlPlaceholders(placeholders)] : []),
76
+ ...plugins,
77
+ ],
70
78
  resolve: {
71
79
  alias: { "@": path.resolve(root, "src") },
72
80
  },