@mgz-app/viteforge 1.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +738 -0
  3. package/dist/index.cjs +3359 -0
  4. package/dist/index.d.ts +319 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.mjs +3319 -0
  7. package/dist/plugins/base64-assets.d.ts +3 -0
  8. package/dist/plugins/base64-assets.d.ts.map +1 -0
  9. package/dist/plugins/calculate-built-size.d.ts +6 -0
  10. package/dist/plugins/calculate-built-size.d.ts.map +1 -0
  11. package/dist/plugins/dev-reload.d.ts +31 -0
  12. package/dist/plugins/dev-reload.d.ts.map +1 -0
  13. package/dist/plugins/glsl/index.d.ts +5 -0
  14. package/dist/plugins/glsl/index.d.ts.map +1 -0
  15. package/dist/plugins/glsl/load-shader.d.ts +4 -0
  16. package/dist/plugins/glsl/load-shader.d.ts.map +1 -0
  17. package/dist/plugins/glsl/types.d.ts +21 -0
  18. package/dist/plugins/glsl/types.d.ts.map +1 -0
  19. package/dist/plugins/glsl-import.d.ts +4 -0
  20. package/dist/plugins/glsl-import.d.ts.map +1 -0
  21. package/dist/plugins/index.cjs +3038 -0
  22. package/dist/plugins/index.d.ts +11 -0
  23. package/dist/plugins/index.d.ts.map +1 -0
  24. package/dist/plugins/index.mjs +3017 -0
  25. package/dist/plugins/inject-nonce.d.ts +6 -0
  26. package/dist/plugins/inject-nonce.d.ts.map +1 -0
  27. package/dist/plugins/post-processing.d.ts +46 -0
  28. package/dist/plugins/post-processing.d.ts.map +1 -0
  29. package/dist/plugins/restart-on-rebuild.d.ts +36 -0
  30. package/dist/plugins/restart-on-rebuild.d.ts.map +1 -0
  31. package/dist/plugins/text-file.d.ts +17 -0
  32. package/dist/plugins/text-file.d.ts.map +1 -0
  33. package/dist/plugins/txt-loader.d.ts +3 -0
  34. package/dist/plugins/txt-loader.d.ts.map +1 -0
  35. package/dist/plugins/worker.d.ts +7 -0
  36. package/dist/plugins/worker.d.ts.map +1 -0
  37. package/package.json +75 -0
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from "vite";
2
+ export interface InjectNoncePluginOptions {
3
+ isDevMode?: boolean;
4
+ }
5
+ export declare function injectNoncePlugin(options?: InjectNoncePluginOptions): Plugin;
6
+ //# sourceMappingURL=inject-nonce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject-nonce.d.ts","sourceRoot":"","sources":["../../src/plugins/inject-nonce.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,MAAM,CA8BhF"}
@@ -0,0 +1,46 @@
1
+ import type { Plugin } from "vite";
2
+ export interface PostProcessingPluginOptions {
3
+ /**
4
+ * Whether to enable compression and obfuscation
5
+ * @default true
6
+ */
7
+ enabled?: boolean;
8
+ /**
9
+ * Compression level (1-9, where 9 is maximum compression)
10
+ * @default 9
11
+ */
12
+ compressionLevel?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
13
+ /**
14
+ * Whether to log compression stats
15
+ * @default true
16
+ */
17
+ logStats?: boolean;
18
+ /**
19
+ * Title for the HTML document
20
+ * @default undefined (no title tag)
21
+ */
22
+ titleString?: string;
23
+ /**
24
+ * SVG string to use as favicon (will be optimized with svgo)
25
+ * @default undefined (no favicon)
26
+ */
27
+ iconString?: string;
28
+ /**
29
+ * Bundle pako inflate runtime instead of using the browser-native DecompressionStream API.
30
+ * Enable this for browsers that don't support DecompressionStream (e.g. Firefox <105, Safari <16.4).
31
+ * @default false
32
+ */
33
+ usePako?: boolean;
34
+ }
35
+ /**
36
+ * Post-processing plugin that compresses the final HTML bundle.
37
+ *
38
+ * This plugin:
39
+ * 1. Extracts all JavaScript from the final HTML
40
+ * 2. Compresses it using pako (deflate/gzip)
41
+ * 3. Wraps it in a self-extracting HTML with embedded pako inflate
42
+ *
43
+ * The result is a smaller file that's also obfuscated (not human-readable).
44
+ */
45
+ export declare function postProcessingPlugin(options?: PostProcessingPluginOptions): Plugin;
46
+ //# sourceMappingURL=post-processing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-processing.d.ts","sourceRoot":"","sources":["../../src/plugins/post-processing.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,MAAM,CAiItF"}
@@ -0,0 +1,36 @@
1
+ import type { Plugin } from "vite";
2
+ export interface RestartOnRebuildPluginOptions {
3
+ /**
4
+ * The command to run after each build completes.
5
+ * This is typically used to start a server process.
6
+ * @example "pnpm run dev:start" or "node ./build/index.js"
7
+ */
8
+ startCommand: string;
9
+ /**
10
+ * Delay in milliseconds before starting the process after build completes.
11
+ * Useful to ensure all files are written before starting.
12
+ * @default 100
13
+ */
14
+ delay?: number;
15
+ }
16
+ /**
17
+ * A Vite plugin that restarts a process after each build.
18
+ * Useful for Node.js server development where you want the server
19
+ * to restart automatically when source files change.
20
+ *
21
+ * Use with `vite build --watch` for development.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // vite.config.ts
26
+ * import { restartOnRebuildPlugin } from "build-utils-vite/plugins";
27
+ *
28
+ * export default defineConfig({
29
+ * plugins: [
30
+ * restartOnRebuildPlugin({ startCommand: "node ./build/index.js" })
31
+ * ]
32
+ * });
33
+ * ```
34
+ */
35
+ export declare function restartOnRebuildPlugin(options: RestartOnRebuildPluginOptions): Plugin;
36
+ //# sourceMappingURL=restart-on-rebuild.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restart-on-rebuild.d.ts","sourceRoot":"","sources":["../../src/plugins/restart-on-rebuild.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B,GAAG,MAAM,CA8CrF"}
@@ -0,0 +1,17 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Vite plugin to handle loading a file as text from a virtual module.
4
+ *
5
+ * Usage:
6
+ * ```ts
7
+ * // In vite.config.ts
8
+ * textFilePlugin("my-virtual-module", "./path/to/file.js")
9
+ *
10
+ * // In code
11
+ * import fileContent from "my-virtual-module";
12
+ * ```
13
+ *
14
+ * Used by mml-networked-dom-web-runner for embedding iframe JS.
15
+ */
16
+ export declare function textFilePlugin(virtualModuleId: string, filePath: string): Plugin;
17
+ //# sourceMappingURL=text-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-file.d.ts","sourceRoot":"","sources":["../../src/plugins/text-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBhF"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "vite";
2
+ export declare function txtLoaderPlugin(): Plugin;
3
+ //# sourceMappingURL=txt-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"txt-loader.d.ts","sourceRoot":"","sources":["../../src/plugins/txt-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,wBAAgB,eAAe,IAAI,MAAM,CA6BxC"}
@@ -0,0 +1,7 @@
1
+ import type { Plugin } from "vite";
2
+ /**
3
+ * Vite plugin that handles .worker imports similar to the esbuild workerPlugin.
4
+ * Compiles worker files as separate bundles and exports a blob URL.
5
+ */
6
+ export declare function workerPlugin(): Plugin;
7
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/plugins/worker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAsErC"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@mgz-app/viteforge",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Build and serve utilities for Vite. Pre-configured presets for apps, packages, and libraries.",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Marco Gomez",
9
+ "email": "me@mgz.me",
10
+ "url": "https://mgz.me"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/marcogomez/viteforge.git"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/index.cjs",
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "require": "./dist/index.cjs",
26
+ "import": "./dist/index.mjs"
27
+ },
28
+ "./plugins": {
29
+ "types": "./dist/plugins/index.d.ts",
30
+ "require": "./dist/plugins/index.cjs",
31
+ "import": "./dist/plugins/index.mjs"
32
+ }
33
+ },
34
+ "scripts": {
35
+ "build": "rimraf dist tsconfig.tsbuildinfo && tsup && tsc --emitDeclarationOnly",
36
+ "dev": "tsup --watch",
37
+ "type-check": "tsc --noEmit",
38
+ "lint": "eslint src --max-warnings 0",
39
+ "lint-fix": "eslint src --fix",
40
+ "test": "vitest run",
41
+ "changeset": "changeset",
42
+ "version": "changeset version",
43
+ "release": "changeset publish"
44
+ },
45
+ "devDependencies": {
46
+ "@changesets/cli": "^2.29.4",
47
+ "@mgz-app/codestyle": "^1.1.0",
48
+ "@types/mime-types": "^3.0.1",
49
+ "@types/node": "^25.0.3",
50
+ "@types/pako": "^2.0.4",
51
+ "@types/resolve": "^1.20.6",
52
+ "esbuild": "^0.25.12",
53
+ "dotenv": "^17.4.2",
54
+ "eslint": "^9.39.4",
55
+ "resolve": "^1.22.12",
56
+ "rimraf": "^6.1.3",
57
+ "tsup": "^8.5.1",
58
+ "typescript": "^5.9.3",
59
+ "vitest": "^4.1.8"
60
+ },
61
+ "dependencies": {
62
+ "mime-types": "^3.0.2",
63
+ "pako": "^2.1.0",
64
+ "svgo": "^4.0.1",
65
+ "tree-kill": "^1.2.2",
66
+ "vite": "^7.3.5",
67
+ "vite-plugin-dts": "^4.5.4",
68
+ "vite-plugin-html": "^3.2.2",
69
+ "vite-plugin-singlefile": "^2.3.3"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "packageManager": "pnpm@10.28.2"
75
+ }