@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.
- package/LICENSE +21 -0
- package/README.md +738 -0
- package/dist/index.cjs +3359 -0
- package/dist/index.d.ts +319 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3319 -0
- package/dist/plugins/base64-assets.d.ts +3 -0
- package/dist/plugins/base64-assets.d.ts.map +1 -0
- package/dist/plugins/calculate-built-size.d.ts +6 -0
- package/dist/plugins/calculate-built-size.d.ts.map +1 -0
- package/dist/plugins/dev-reload.d.ts +31 -0
- package/dist/plugins/dev-reload.d.ts.map +1 -0
- package/dist/plugins/glsl/index.d.ts +5 -0
- package/dist/plugins/glsl/index.d.ts.map +1 -0
- package/dist/plugins/glsl/load-shader.d.ts +4 -0
- package/dist/plugins/glsl/load-shader.d.ts.map +1 -0
- package/dist/plugins/glsl/types.d.ts +21 -0
- package/dist/plugins/glsl/types.d.ts.map +1 -0
- package/dist/plugins/glsl-import.d.ts +4 -0
- package/dist/plugins/glsl-import.d.ts.map +1 -0
- package/dist/plugins/index.cjs +3038 -0
- package/dist/plugins/index.d.ts +11 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.mjs +3017 -0
- package/dist/plugins/inject-nonce.d.ts +6 -0
- package/dist/plugins/inject-nonce.d.ts.map +1 -0
- package/dist/plugins/post-processing.d.ts +46 -0
- package/dist/plugins/post-processing.d.ts.map +1 -0
- package/dist/plugins/restart-on-rebuild.d.ts +36 -0
- package/dist/plugins/restart-on-rebuild.d.ts.map +1 -0
- package/dist/plugins/text-file.d.ts +17 -0
- package/dist/plugins/text-file.d.ts.map +1 -0
- package/dist/plugins/txt-loader.d.ts +3 -0
- package/dist/plugins/txt-loader.d.ts.map +1 -0
- package/dist/plugins/worker.d.ts +7 -0
- package/dist/plugins/worker.d.ts.map +1 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import dts from "vite-plugin-dts";
|
|
2
|
+
import type { ConfigEnv, Plugin, PluginOption, UserConfig } from "vite";
|
|
3
|
+
export interface ViteConfigOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The root directory of the app
|
|
6
|
+
*/
|
|
7
|
+
root?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Development server port
|
|
10
|
+
* @default 4173
|
|
11
|
+
*/
|
|
12
|
+
port?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Preview server port
|
|
15
|
+
* @default 4174
|
|
16
|
+
*/
|
|
17
|
+
previewPort?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Output directory
|
|
20
|
+
* @default "./dist"
|
|
21
|
+
*/
|
|
22
|
+
outDir?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Cache directory
|
|
25
|
+
* @default "../../node_modules/.vite"
|
|
26
|
+
*/
|
|
27
|
+
cacheDir?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to use single file build
|
|
30
|
+
* @default true for build, false for dev
|
|
31
|
+
*/
|
|
32
|
+
singleFile?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to minify HTML
|
|
35
|
+
* @default true for build, false for dev
|
|
36
|
+
*/
|
|
37
|
+
minifyHtml?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to minify JavaScript
|
|
40
|
+
* @default true for build, false for dev
|
|
41
|
+
*/
|
|
42
|
+
minify?: boolean | "terser" | "esbuild";
|
|
43
|
+
/**
|
|
44
|
+
* Whether to use base64 asset plugin
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
useBase64Assets?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to inject nonce for CSP
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
useNonceInjection?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to calculate built size
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
calculateBuiltSize?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether in development mode (affects CSP)
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
isDevMode?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Additional plugins to add
|
|
65
|
+
*/
|
|
66
|
+
additionalPlugins?: any[];
|
|
67
|
+
}
|
|
68
|
+
export declare const terserOptions: {
|
|
69
|
+
mangle: {
|
|
70
|
+
eval: boolean;
|
|
71
|
+
keep_fnames: boolean;
|
|
72
|
+
module: boolean;
|
|
73
|
+
toplevel: boolean;
|
|
74
|
+
safari10: boolean;
|
|
75
|
+
};
|
|
76
|
+
compress: {
|
|
77
|
+
drop_console: boolean;
|
|
78
|
+
drop_debugger: boolean;
|
|
79
|
+
passes: number;
|
|
80
|
+
};
|
|
81
|
+
format: {
|
|
82
|
+
comments: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Creates a base Vite configuration for applications.
|
|
87
|
+
*/
|
|
88
|
+
export declare function defineViteConfig(options?: ViteConfigOptions): (env: ConfigEnv) => UserConfig;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a Vite configuration preset for single-page applications.
|
|
91
|
+
* - Dev mode: No minification, readable output, fast HMR
|
|
92
|
+
* - Build mode: Full optimization with minification, single file output
|
|
93
|
+
*/
|
|
94
|
+
export declare function defineAppConfig(options?: ViteConfigOptions): (env: ConfigEnv) => UserConfig;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a Vite configuration preset for reusable packages.
|
|
97
|
+
* - Dev mode: No minification, readable output, fast HMR
|
|
98
|
+
* - Build mode: Full optimization with minification, single file output
|
|
99
|
+
*/
|
|
100
|
+
export declare function definePackageConfig(options?: ViteConfigOptions): (env: ConfigEnv) => UserConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Library build presets for different distribution targets
|
|
103
|
+
*/
|
|
104
|
+
export type LibraryPreset = "internal" | "npm-esm" | "npm-full" | "cdn" | "universal";
|
|
105
|
+
export interface LibraryConfigOptions {
|
|
106
|
+
/**
|
|
107
|
+
* Package name (e.g., "@my-org/my-lib")
|
|
108
|
+
* Used for lib.name and test.name
|
|
109
|
+
*/
|
|
110
|
+
name: string;
|
|
111
|
+
/**
|
|
112
|
+
* Entry point file
|
|
113
|
+
* @default "src/index.ts"
|
|
114
|
+
*/
|
|
115
|
+
entry?: string;
|
|
116
|
+
/**
|
|
117
|
+
* External dependencies that should not be bundled.
|
|
118
|
+
* Can be strings or RegExp patterns.
|
|
119
|
+
* @example ["three", /^@some-org\//]
|
|
120
|
+
*/
|
|
121
|
+
external?: (string | RegExp)[];
|
|
122
|
+
/**
|
|
123
|
+
* Test environment
|
|
124
|
+
* @default "node"
|
|
125
|
+
*/
|
|
126
|
+
testEnvironment?: "node" | "jsdom";
|
|
127
|
+
/**
|
|
128
|
+
* Test setup files (relative paths from package root)
|
|
129
|
+
* @example ["./test/vitest.setup.ts", "../../test-utils/vitest-canvas-mock.ts"]
|
|
130
|
+
*/
|
|
131
|
+
setupFiles?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Test timeout in milliseconds
|
|
134
|
+
* @default undefined (uses vitest default)
|
|
135
|
+
*/
|
|
136
|
+
testTimeout?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Whether tests should pass if no test files are found
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
passWithNoTests?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Additional plugins to add
|
|
144
|
+
*/
|
|
145
|
+
additionalPlugins?: Plugin[];
|
|
146
|
+
/**
|
|
147
|
+
* Build behavior based on mode:
|
|
148
|
+
* - "mode-aware": sourcemap in dev only, minify in prod only (default)
|
|
149
|
+
* - "static": always sourcemap, never minify
|
|
150
|
+
* @default "mode-aware"
|
|
151
|
+
*/
|
|
152
|
+
buildMode?: "mode-aware" | "static";
|
|
153
|
+
/**
|
|
154
|
+
* Enable base64 asset imports plugin.
|
|
155
|
+
* Allows importing files with ?base64 query to get base64 encoded content.
|
|
156
|
+
* Used for embedding WASM/JS files as base64 strings.
|
|
157
|
+
* @example import wasmBase64 from "./file.wasm?base64";
|
|
158
|
+
* @default false
|
|
159
|
+
*/
|
|
160
|
+
useBase64Assets?: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Output directory
|
|
163
|
+
* @default "./build"
|
|
164
|
+
*/
|
|
165
|
+
outDir?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Library build preset. Determines which output formats are generated.
|
|
168
|
+
* - "internal": ES only (for monorepo internal use)
|
|
169
|
+
* - "npm-esm": ES + types (modern npm packages)
|
|
170
|
+
* - "npm-full": ES + CJS + types (maximum npm compatibility)
|
|
171
|
+
* - "cdn": UMD + IIFE minified (for script tags/CDN)
|
|
172
|
+
* - "universal": ALL formats (ES, CJS, UMD, IIFE + minified variants)
|
|
173
|
+
* @default "npm-full"
|
|
174
|
+
*/
|
|
175
|
+
preset?: LibraryPreset;
|
|
176
|
+
/**
|
|
177
|
+
* Output formats for the library. Overrides preset if specified.
|
|
178
|
+
* @deprecated Use `preset` instead for standard configurations
|
|
179
|
+
*/
|
|
180
|
+
formats?: ("es" | "cjs" | "umd" | "iife")[];
|
|
181
|
+
/**
|
|
182
|
+
* Global variable name for UMD/IIFE builds (e.g., "MyLibrary").
|
|
183
|
+
* Auto-generated from package name if not specified.
|
|
184
|
+
* Only used when UMD or IIFE formats are included.
|
|
185
|
+
* @example "Statecraft" for window.Statecraft
|
|
186
|
+
*/
|
|
187
|
+
globalName?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Whether to generate separate minified bundles for UMD/IIFE formats.
|
|
190
|
+
* Creates both index.umd.js and index.umd.min.js
|
|
191
|
+
* @default true when preset includes UMD/IIFE
|
|
192
|
+
*/
|
|
193
|
+
minifiedBundles?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* Whether to roll up .d.ts files into a single file
|
|
196
|
+
* @default true
|
|
197
|
+
*/
|
|
198
|
+
rollupTypes?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Whether to always empty the output directory on build
|
|
201
|
+
* @default true
|
|
202
|
+
*/
|
|
203
|
+
alwaysEmptyOutDir?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Whether to preserve the module structure in the output.
|
|
206
|
+
* When true, Rollup emits one file per source module instead of bundling
|
|
207
|
+
* everything into a single chunk. This enables fine-grained tree-shaking
|
|
208
|
+
* in consuming bundlers.
|
|
209
|
+
*
|
|
210
|
+
* Only applies to ES and CJS formats (UMD/IIFE require bundling).
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
preserveModules?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Global variable mappings for UMD/IIFE external dependencies.
|
|
216
|
+
* Maps npm package names to the global variable they expose at runtime.
|
|
217
|
+
* @example { three: "THREE", react: "React", "react-dom": "ReactDOM" }
|
|
218
|
+
*/
|
|
219
|
+
globals?: Record<string, string>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Creates a Vite configuration preset for library packages.
|
|
223
|
+
* Supports all distribution formats.
|
|
224
|
+
*
|
|
225
|
+
* Features:
|
|
226
|
+
* - Automatic TypeScript declaration generation (dts plugin)
|
|
227
|
+
* - Multiple output formats: ES, CJS, UMD, IIFE
|
|
228
|
+
* - Preset system for common configurations
|
|
229
|
+
* - Separate minified bundles for CDN distribution
|
|
230
|
+
* - Proper file extensions (.mjs, .cjs, .umd.js, .iife.js)
|
|
231
|
+
* - Auto-generated global name for UMD/IIFE
|
|
232
|
+
* - External dependencies not bundled
|
|
233
|
+
* - Vitest configuration included
|
|
234
|
+
* - Mode-aware or static build options
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* // Simple usage with preset (recommended)
|
|
239
|
+
* export default defineConfig(
|
|
240
|
+
* defineLibraryConfig({
|
|
241
|
+
* name: "my-lib",
|
|
242
|
+
* preset: "npm-full"
|
|
243
|
+
* })
|
|
244
|
+
* );
|
|
245
|
+
*
|
|
246
|
+
* // Universal distribution (all formats)
|
|
247
|
+
* export default defineConfig(
|
|
248
|
+
* defineLibraryConfig({
|
|
249
|
+
* name: "@my-org/model-loader",
|
|
250
|
+
* preset: "universal",
|
|
251
|
+
* globalName: "ModelLoader",
|
|
252
|
+
* external: ["three"],
|
|
253
|
+
* globals: { three: "THREE" }
|
|
254
|
+
* })
|
|
255
|
+
* );
|
|
256
|
+
*
|
|
257
|
+
* // CDN-only distribution
|
|
258
|
+
* export default defineConfig(
|
|
259
|
+
* defineLibraryConfig({
|
|
260
|
+
* name: "@my-org/widget",
|
|
261
|
+
* preset: "cdn",
|
|
262
|
+
* globalName: "Widget"
|
|
263
|
+
* })
|
|
264
|
+
* );
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
export declare function defineLibraryConfig(options: LibraryConfigOptions): (env: ConfigEnv) => {
|
|
268
|
+
root: string;
|
|
269
|
+
cacheDir: string;
|
|
270
|
+
plugins: PluginOption[];
|
|
271
|
+
build: {
|
|
272
|
+
outDir: string;
|
|
273
|
+
emptyOutDir: boolean;
|
|
274
|
+
reportCompressedSize: boolean;
|
|
275
|
+
sourcemap: boolean;
|
|
276
|
+
minify: boolean | "terser";
|
|
277
|
+
terserOptions: {
|
|
278
|
+
mangle: {
|
|
279
|
+
eval: boolean;
|
|
280
|
+
keep_fnames: boolean;
|
|
281
|
+
module: boolean;
|
|
282
|
+
toplevel: boolean;
|
|
283
|
+
safari10: boolean;
|
|
284
|
+
};
|
|
285
|
+
compress: {
|
|
286
|
+
drop_console: boolean;
|
|
287
|
+
drop_debugger: boolean;
|
|
288
|
+
passes: number;
|
|
289
|
+
};
|
|
290
|
+
format: {
|
|
291
|
+
comments: boolean;
|
|
292
|
+
};
|
|
293
|
+
} | undefined;
|
|
294
|
+
commonjsOptions: {
|
|
295
|
+
transformMixedEsModules: boolean;
|
|
296
|
+
};
|
|
297
|
+
lib: {
|
|
298
|
+
entry: string;
|
|
299
|
+
name: string;
|
|
300
|
+
fileName: (format: string) => string;
|
|
301
|
+
formats: ("es" | "cjs" | "umd" | "iife")[];
|
|
302
|
+
};
|
|
303
|
+
rollupOptions: {
|
|
304
|
+
external: (string | RegExp)[];
|
|
305
|
+
output: {
|
|
306
|
+
preserveModules?: boolean | undefined;
|
|
307
|
+
preserveModulesRoot?: string | undefined;
|
|
308
|
+
globals: (id: string) => string;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
test: Record<string, unknown>;
|
|
313
|
+
};
|
|
314
|
+
export * from "./plugins/index.js";
|
|
315
|
+
export { resolve } from "path";
|
|
316
|
+
export { defineConfig, mergeConfig } from "vite";
|
|
317
|
+
export { dts };
|
|
318
|
+
export type { Plugin };
|
|
319
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAMlC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACxC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH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