@getvitops/vite 0.1.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 +27 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +59 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @getvitops/vite
|
|
2
|
+
|
|
3
|
+
A Vite plugin that generates Vitops design-system output from a `design-system.json` during a
|
|
4
|
+
Vite/Astro (EmDash) build — and hot-regenerates when the config changes in dev.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
// astro.config.mjs / vite.config.ts
|
|
8
|
+
import vitops from '@getvitops/vite';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
plugins: [
|
|
12
|
+
vitops({
|
|
13
|
+
input: 'design-system.json', // default
|
|
14
|
+
format: 'tailwind', // 'bricks' | 'css' | 'tailwind' (default: 'tailwind')
|
|
15
|
+
out: 'src/styles', // default
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then import the generated stylesheet (Tailwind v4):
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
@import './styles/tailwind.css';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Powered by [`@getvitops/generator`](https://www.npmjs.com/package/@getvitops/generator).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Format } from "@getvitops/generator";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
interface VitopsFaviconOptions {
|
|
6
|
+
/** Source SVG or PNG. */
|
|
7
|
+
source: string;
|
|
8
|
+
/** Optional simplified source for the 16px icon. */
|
|
9
|
+
lowResSource?: string;
|
|
10
|
+
/** Directory to write the favicon set into. Default: 'public'. */
|
|
11
|
+
out?: string;
|
|
12
|
+
}
|
|
13
|
+
interface VitopsPluginOptions {
|
|
14
|
+
/** Path to the design-system.json. Default: 'design-system.json'. */
|
|
15
|
+
input?: string;
|
|
16
|
+
/** Output target. Default: 'tailwind' (the EmDash/Astro case). */
|
|
17
|
+
format?: Format;
|
|
18
|
+
/** Directory to write generated output into. Default: 'src/styles'. */
|
|
19
|
+
out?: string;
|
|
20
|
+
/** Also generate a favicon set on build from this source image. */
|
|
21
|
+
favicon?: VitopsFaviconOptions;
|
|
22
|
+
}
|
|
23
|
+
declare function vitops(options?: VitopsPluginOptions): Plugin;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { VitopsFaviconOptions, VitopsPluginOptions, vitops as default };
|
|
26
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { generate } from "@getvitops/generator";
|
|
3
|
+
import { generateFavicons } from "@getvitops/utils";
|
|
4
|
+
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
/**
|
|
7
|
+
* @getvitops/vite — a Vite plugin that generates Vitops design-system output from a
|
|
8
|
+
* `design-system.json` during a Vite/Astro (EmDash) build, and hot-regenerates when
|
|
9
|
+
* the config changes in dev.
|
|
10
|
+
*
|
|
11
|
+
* import vitops from '@getvitops/vite';
|
|
12
|
+
* export default { plugins: [vitops({ input: 'design-system.json', format: 'tailwind', out: 'src/styles' })] };
|
|
13
|
+
*
|
|
14
|
+
* Thin wrapper over @getvitops/generator — the same generator the CLI uses.
|
|
15
|
+
*/
|
|
16
|
+
function vitops(options = {}) {
|
|
17
|
+
const format = options.format ?? "tailwind";
|
|
18
|
+
const outDir = options.out ?? "src/styles";
|
|
19
|
+
let input = resolve(options.input ?? "design-system.json");
|
|
20
|
+
let root = "";
|
|
21
|
+
const run = async () => {
|
|
22
|
+
await generate({
|
|
23
|
+
input,
|
|
24
|
+
format,
|
|
25
|
+
outDir
|
|
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
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
name: "@getvitops/vite",
|
|
35
|
+
configResolved(config) {
|
|
36
|
+
root = config.root;
|
|
37
|
+
input = resolve(config.root, options.input ?? "design-system.json");
|
|
38
|
+
},
|
|
39
|
+
async buildStart() {
|
|
40
|
+
this.addWatchFile(input);
|
|
41
|
+
await run();
|
|
42
|
+
},
|
|
43
|
+
async watchChange(id) {
|
|
44
|
+
if (resolve(id) === input) await run();
|
|
45
|
+
},
|
|
46
|
+
configureServer(server) {
|
|
47
|
+
server.watcher.add(input);
|
|
48
|
+
server.watcher.on("change", async (file) => {
|
|
49
|
+
if (resolve(file) !== input) return;
|
|
50
|
+
await run();
|
|
51
|
+
server.ws.send({ type: "full-reload" });
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { vitops as default };
|
|
59
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@getvitops/vite",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vite plugin that generates Vitops design-system outputs from a design-system.json during a Vite/Astro build.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"import": "./dist/index.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@getvitops/generator": "0.1.0",
|
|
21
|
+
"@getvitops/utils": "0.1.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"vite": "^6.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vite": ">=5"
|
|
28
|
+
}
|
|
29
|
+
}
|