@ugreen-nas/builder-open API
Public Vite API, parameters, types, and usage for @ugreen-nas/builder-open.
Quick index
| Scenario | Section |
|---|---|
Wire the plugin in vite.config.ts | UgosViteBuilder, pluginEntry |
Main window metadata, version.json | BuildConfig |
Imports
ts
import { UgosViteBuilder } from '@ugreen-nas/builder-open';
import type { BuildConfig } from '@ugreen-nas/builder-open';ts
// Optional: subpath equivalent
import { UgosViteBuilder } from '@ugreen-nas/builder-open/vite';API summary
| Symbol | Kind | Description |
|---|---|---|
UgosViteBuilder | class | Vite-facing builder |
BuildConfig | type | Build config (types from @ugreen-nas/builder-core) |
pluginEntry | method | Returns Vite plugin array |
UgosViteBuilder
Constructor
ts
constructor(config: BuildConfig);| Param | Type | Required | Description |
|---|---|---|---|
config | BuildConfig | Yes | Build and artifact metadata |
Use pluginEntry() inside defineConfig({ plugins }) (see pluginEntry and Minimal example).
pluginEntry(options?)
ts
pluginEntry(options?: IPluginEntry): never[];Declared as never[]; actually import('vite').Plugin[]. Spread into plugins:
ts
plugins: [...builder.pluginEntry()],IPluginEntry
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
mode | string | No | '' | 'analyze' enables bundle analysis via hooks.vitePlugins |
removeConsoleExternal | string[] | No | [] | Extra externals for vite-plugin-remove-console |
BuildConfig
Fields
| Field | Type | Required | Default / notes |
|---|---|---|---|
windowConfig | unknown | Strongly recommended | Shell window config; validation errors if missing |
getIgnoreFolder | (config: unknown, isElectron: boolean) => unknown | Yes | Ignore globs; often merged with ['**/node_modules/**'] |
langPath | string | No | Default 'src/language' |
Minimal example
ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { UgosViteBuilder } from '@ugreen-nas/builder-open';
import path from 'node:path';
const builder = new UgosViteBuilder({
windowConfig: { width: 1200, height: 800 },
getIgnoreFolder: (patterns: unknown) => patterns,
});
export default defineConfig({
plugins: [react(), ...builder.pluginEntry()],
});