@coresystems/config-vite
v2.0.0
Published
Shared Vite configurations for coresystems
Readme
@coresystems/config-vite
Factory functions for Vite configuration.
| Function | Use case |
| ---------------------- | ----------------------- |
| defineReactAppConfig | React application |
| defineReactLibConfig | React component library |
Usage
Both factories accept either an options object or a callback (env: ConfigEnv) => options — mirroring Vite's native defineConfig API.
Both are re-exported from the package root:
import { defineReactAppConfig, defineReactLibConfig } from '@coresystems/config-vite';Options object
// vite.config.ts
export default defineReactAppConfig({ port: 3000 });Callback form
// vite.config.ts
export default defineReactAppConfig(({ mode }) => ({
proxy: mode === 'development' ? { '/api': { target: import.meta.VITE_API_URL, changeOrigin: true } } : undefined,
}));defineReactAppConfig
Dev server app with HMR. Includes react() plugin.
// vite.config.ts
import { defineReactAppConfig } from '@coresystems/config-vite/react-app';
export default defineReactAppConfig({ port: 3000 });Options
| Option | Type | Default | Description |
| -------------- | ---------------------------------------- | ------- | --------------------------------------------------------------------- |
| port | number | 5173 | Dev server port |
| host | string \| boolean | — | IP addresses to listen on. Use '0.0.0.0' for LAN/public access. |
| proxy | Record<string, string \| ProxyOptions> | — | Dev server proxy rules (server.proxy) |
| watch | WatchOptions \| null | — | Chokidar watch options, or null to disable file-system watching. |
| alias | AliasOptions \| 'match-tsconfig' | — | Path aliases. Pass 'match-tsconfig' to resolve from tsconfig paths. |
| extraPlugins | PluginOption[] | [] | Additional plugins. react() is already included. |
defineReactLibConfig
Lib mode with dual ESM/CJS output. Includes react() + dts() plugins. React is always external — never bundled.
// vite.config.ts
import { defineReactLibConfig } from '@coresystems/config-vite/react-lib';
export default defineReactLibConfig({ entry: 'src/index.ts' });Base options
| Option | Type | Default | Description |
| -------------- | ---------------------------------- | ------- | --------------------------------------------------------------------- |
| alias | AliasOptions \| 'match-tsconfig' | — | Path aliases. Pass 'match-tsconfig' to resolve from tsconfig paths. |
| extraPlugins | PluginOption[] | [] | Additional plugins. react() and dts() are already included. |
Build options
| Option | Type | Default | Description |
| ---------- | ---------------------------------- | --------------------------------------------- | ----------------------------------------------------------------- |
| entry | string \| Record<string, string> | required | Library entry point(s). Pass a record for multiple named entries. |
| name | string | — | Global variable name exposed in UMD/IIFE builds. |
| formats | LibraryFormats[] | ['es', 'cjs'] | Output bundle formats. |
| external | string[] | ['react', 'react-dom', 'react/jsx-runtime'] | Module IDs to exclude from the bundle. |
DTS options
| Option | Type | Default | Description |
| ------------------- | ---------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| shouldRollupTypes | boolean | — | Rollup type declaration files into a single .d.ts after emitting them. |
| tsconfigPath | string | 'tsconfig.json' | Absolute path to the tsconfig used for declaration generation. Override when using a non-standard tsconfig path — pass resolve(import.meta.dirname, 'tsconfig.build.json'). |
| excludeFromDts | string[] | ['**/*.stories.*', '**/*.test.*', '**/*.spec.*', '**/*.config.*', '**/tests/**'] | Glob patterns excluded from type declaration generation. |
