@getvitops/vite 0.1.0 → 0.2.1

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.d.mts CHANGED
@@ -9,6 +9,12 @@ interface VitopsFaviconOptions {
9
9
  lowResSource?: string;
10
10
  /** Directory to write the favicon set into. Default: 'public'. */
11
11
  out?: string;
12
+ /** App name — when set (with `themeColor`), also emit `site.webmanifest`. */
13
+ name?: string;
14
+ /** PWA theme color (also drives `<meta name="theme-color">`). */
15
+ themeColor?: string;
16
+ /** PWA background color. */
17
+ backgroundColor?: string;
12
18
  }
13
19
  interface VitopsPluginOptions {
14
20
  /** Path to the design-system.json. Default: 'design-system.json'. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UAeiB,oBAAA;;EAEf,MAAA;EAFmC;EAInC,YAAA;EAJmC;EAMnC,GAAA;AAAA;AAAA,UAGe,mBAAA;EAHZ;EAKH,KAAA;EAFe;EAIf,MAAA,GAAS,MAAA;;EAET,GAAA;EAJA;EAMA,OAAA,GAAU,oBAAoB;AAAA;AAAA,iBAGR,MAAA,CAAO,OAAA,GAAS,mBAAA,GAA2B,MAAM"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UAeiB,oBAAA;;EAEf,MAAA;EAFmC;EAInC,YAAA;EAJmC;EAMnC,GAAA;EAFA;EAIA,IAAA;EAAA;EAEA,UAAA;EAEA;EAAA,eAAA;AAAA;AAAA,UAGe,mBAAA;EAAmB;EAElC,KAAA;EAM8B;EAJ9B,MAAA,GAAS,MAAA;EAAT;EAEA,GAAA;EAAA;EAEA,OAAA,GAAU,oBAAoB;AAAA;AAAA,iBAGR,MAAA,CAAO,OAAA,GAAS,mBAAA,GAA2B,MAAM"}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { resolve } from "node:path";
2
2
  import { generate } from "@getvitops/generator";
3
- import { generateFavicons } from "@getvitops/utils";
3
+ import { generateFavicons, writeFaviconManifest } from "@getvitops/utils";
4
4
 
5
5
  //#region src/index.ts
6
6
  /**
@@ -24,11 +24,19 @@ function vitops(options = {}) {
24
24
  format,
25
25
  outDir
26
26
  });
27
- if (options.favicon) await generateFavicons({
28
- source: resolve(root, options.favicon.source),
29
- outputDir: resolve(root, options.favicon.out ?? "public"),
30
- ...options.favicon.lowResSource ? { lowResSource: resolve(root, options.favicon.lowResSource) } : {}
31
- });
27
+ if (options.favicon) {
28
+ const faviconOut = resolve(root, options.favicon.out ?? "public");
29
+ await generateFavicons({
30
+ source: resolve(root, options.favicon.source),
31
+ outputDir: faviconOut,
32
+ ...options.favicon.lowResSource ? { lowResSource: resolve(root, options.favicon.lowResSource) } : {}
33
+ });
34
+ if (options.favicon.name && options.favicon.themeColor) await writeFaviconManifest(faviconOut, {
35
+ name: options.favicon.name,
36
+ themeColor: options.favicon.themeColor,
37
+ ...options.favicon.backgroundColor ? { backgroundColor: options.favicon.backgroundColor } : {}
38
+ });
39
+ }
32
40
  };
33
41
  return {
34
42
  name: "@getvitops/vite",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @getvitops/vite — a Vite plugin that generates Vitops design-system output from a\n * `design-system.json` during a Vite/Astro (EmDash) build, and hot-regenerates when\n * the config changes in dev.\n *\n * import vitops from '@getvitops/vite';\n * export default { plugins: [vitops({ input: 'design-system.json', format: 'tailwind', out: 'src/styles' })] };\n *\n * Thin wrapper over @getvitops/generator — the same generator the CLI uses.\n */\nimport { resolve } from 'node:path';\nimport type { Plugin } from 'vite';\nimport { generate, type Format } from '@getvitops/generator';\nimport { generateFavicons } from '@getvitops/utils';\n\nexport interface VitopsFaviconOptions {\n /** Source SVG or PNG. */\n source: string;\n /** Optional simplified source for the 16px icon. */\n lowResSource?: string;\n /** Directory to write the favicon set into. Default: 'public'. */\n out?: string;\n}\n\nexport interface VitopsPluginOptions {\n /** Path to the design-system.json. Default: 'design-system.json'. */\n input?: string;\n /** Output target. Default: 'tailwind' (the EmDash/Astro case). */\n format?: Format;\n /** Directory to write generated output into. Default: 'src/styles'. */\n out?: string;\n /** Also generate a favicon set on build from this source image. */\n favicon?: VitopsFaviconOptions;\n}\n\nexport default function vitops(options: VitopsPluginOptions = {}): Plugin {\n const format: Format = options.format ?? 'tailwind';\n const outDir = options.out ?? 'src/styles';\n let input = resolve(options.input ?? 'design-system.json');\n let root = '';\n\n const run = async () => {\n await generate({ input, format, outDir });\n if (options.favicon) {\n await generateFavicons({\n source: resolve(root, options.favicon.source),\n outputDir: resolve(root, options.favicon.out ?? 'public'),\n ...(options.favicon.lowResSource\n ? { lowResSource: resolve(root, options.favicon.lowResSource) }\n : {}),\n });\n }\n };\n\n return {\n name: '@getvitops/vite',\n // Resolve paths against Vite's project root once it's known.\n configResolved(config) {\n root = config.root;\n input = resolve(config.root, options.input ?? 'design-system.json');\n },\n async buildStart() {\n this.addWatchFile(input);\n await run();\n },\n async watchChange(id) {\n if (resolve(id) === input) await run();\n },\n configureServer(server) {\n server.watcher.add(input);\n server.watcher.on('change', async (file) => {\n if (resolve(file) !== input) return;\n await run();\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmCA,SAAwB,OAAO,UAA+B,CAAC,GAAW;CACxE,MAAM,SAAiB,QAAQ,UAAU;CACzC,MAAM,SAAS,QAAQ,OAAO;CAC9B,IAAI,QAAQ,QAAQ,QAAQ,SAAS,oBAAoB;CACzD,IAAI,OAAO;CAEX,MAAM,MAAM,YAAY;EACtB,MAAM,SAAS;GAAE;GAAO;GAAQ;EAAO,CAAC;EACxC,IAAI,QAAQ,SACV,MAAM,iBAAiB;GACrB,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,MAAM;GAC5C,WAAW,QAAQ,MAAM,QAAQ,QAAQ,OAAO,QAAQ;GACxD,GAAI,QAAQ,QAAQ,eAChB,EAAE,cAAc,QAAQ,MAAM,QAAQ,QAAQ,YAAY,EAAE,IAC5D,CAAC;EACP,CAAC;CAEL;CAEA,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,QAAQ,QAAQ,OAAO,MAAM,QAAQ,SAAS,oBAAoB;EACpE;EACA,MAAM,aAAa;GACjB,KAAK,aAAa,KAAK;GACvB,MAAM,IAAI;EACZ;EACA,MAAM,YAAY,IAAI;GACpB,IAAI,QAAQ,EAAE,MAAM,OAAO,MAAM,IAAI;EACvC;EACA,gBAAgB,QAAQ;GACtB,OAAO,QAAQ,IAAI,KAAK;GACxB,OAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;IAC1C,IAAI,QAAQ,IAAI,MAAM,OAAO;IAC7B,MAAM,IAAI;IACV,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;GACxC,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @getvitops/vite — a Vite plugin that generates Vitops design-system output from a\n * `design-system.json` during a Vite/Astro (EmDash) build, and hot-regenerates when\n * the config changes in dev.\n *\n * import vitops from '@getvitops/vite';\n * export default { plugins: [vitops({ input: 'design-system.json', format: 'tailwind', out: 'src/styles' })] };\n *\n * Thin wrapper over @getvitops/generator — the same generator the CLI uses.\n */\nimport { resolve } from 'node:path';\nimport type { Plugin } from 'vite';\nimport { generate, type Format } from '@getvitops/generator';\nimport { generateFavicons, writeFaviconManifest } from '@getvitops/utils';\n\nexport interface VitopsFaviconOptions {\n /** Source SVG or PNG. */\n source: string;\n /** Optional simplified source for the 16px icon. */\n lowResSource?: string;\n /** Directory to write the favicon set into. Default: 'public'. */\n out?: string;\n /** App name — when set (with `themeColor`), also emit `site.webmanifest`. */\n name?: string;\n /** PWA theme color (also drives `<meta name=\"theme-color\">`). */\n themeColor?: string;\n /** PWA background color. */\n backgroundColor?: string;\n}\n\nexport interface VitopsPluginOptions {\n /** Path to the design-system.json. Default: 'design-system.json'. */\n input?: string;\n /** Output target. Default: 'tailwind' (the EmDash/Astro case). */\n format?: Format;\n /** Directory to write generated output into. Default: 'src/styles'. */\n out?: string;\n /** Also generate a favicon set on build from this source image. */\n favicon?: VitopsFaviconOptions;\n}\n\nexport default function vitops(options: VitopsPluginOptions = {}): Plugin {\n const format: Format = options.format ?? 'tailwind';\n const outDir = options.out ?? 'src/styles';\n let input = resolve(options.input ?? 'design-system.json');\n let root = '';\n\n const run = async () => {\n await generate({ input, format, outDir });\n if (options.favicon) {\n const faviconOut = resolve(root, options.favicon.out ?? 'public');\n await generateFavicons({\n source: resolve(root, options.favicon.source),\n outputDir: faviconOut,\n ...(options.favicon.lowResSource\n ? { lowResSource: resolve(root, options.favicon.lowResSource) }\n : {}),\n });\n if (options.favicon.name && options.favicon.themeColor) {\n await writeFaviconManifest(faviconOut, {\n name: options.favicon.name,\n themeColor: options.favicon.themeColor,\n ...(options.favicon.backgroundColor\n ? { backgroundColor: options.favicon.backgroundColor }\n : {}),\n });\n }\n }\n };\n\n return {\n name: '@getvitops/vite',\n // Resolve paths against Vite's project root once it's known.\n configResolved(config) {\n root = config.root;\n input = resolve(config.root, options.input ?? 'design-system.json');\n },\n async buildStart() {\n this.addWatchFile(input);\n await run();\n },\n async watchChange(id) {\n if (resolve(id) === input) await run();\n },\n configureServer(server) {\n server.watcher.add(input);\n server.watcher.on('change', async (file) => {\n if (resolve(file) !== input) return;\n await run();\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,SAAwB,OAAO,UAA+B,CAAC,GAAW;CACxE,MAAM,SAAiB,QAAQ,UAAU;CACzC,MAAM,SAAS,QAAQ,OAAO;CAC9B,IAAI,QAAQ,QAAQ,QAAQ,SAAS,oBAAoB;CACzD,IAAI,OAAO;CAEX,MAAM,MAAM,YAAY;EACtB,MAAM,SAAS;GAAE;GAAO;GAAQ;EAAO,CAAC;EACxC,IAAI,QAAQ,SAAS;GACnB,MAAM,aAAa,QAAQ,MAAM,QAAQ,QAAQ,OAAO,QAAQ;GAChE,MAAM,iBAAiB;IACrB,QAAQ,QAAQ,MAAM,QAAQ,QAAQ,MAAM;IAC5C,WAAW;IACX,GAAI,QAAQ,QAAQ,eAChB,EAAE,cAAc,QAAQ,MAAM,QAAQ,QAAQ,YAAY,EAAE,IAC5D,CAAC;GACP,CAAC;GACD,IAAI,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,YAC1C,MAAM,qBAAqB,YAAY;IACrC,MAAM,QAAQ,QAAQ;IACtB,YAAY,QAAQ,QAAQ;IAC5B,GAAI,QAAQ,QAAQ,kBAChB,EAAE,iBAAiB,QAAQ,QAAQ,gBAAgB,IACnD,CAAC;GACP,CAAC;EAEL;CACF;CAEA,OAAO;EACL,MAAM;EAEN,eAAe,QAAQ;GACrB,OAAO,OAAO;GACd,QAAQ,QAAQ,OAAO,MAAM,QAAQ,SAAS,oBAAoB;EACpE;EACA,MAAM,aAAa;GACjB,KAAK,aAAa,KAAK;GACvB,MAAM,IAAI;EACZ;EACA,MAAM,YAAY,IAAI;GACpB,IAAI,QAAQ,EAAE,MAAM,OAAO,MAAM,IAAI;EACvC;EACA,gBAAgB,QAAQ;GACtB,OAAO,QAAQ,IAAI,KAAK;GACxB,OAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;IAC1C,IAAI,QAAQ,IAAI,MAAM,OAAO;IAC7B,MAAM,IAAI;IACV,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;GACxC,CAAC;EACH;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getvitops/vite",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Vite plugin that generates Vitops design-system outputs from a design-system.json during a Vite/Astro build.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,8 +17,8 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@getvitops/generator": "0.1.0",
21
- "@getvitops/utils": "0.1.0"
20
+ "@getvitops/generator": "0.2.1",
21
+ "@getvitops/utils": "0.2.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "vite": "^6.0.0"