@esmx/vite
The Vite package provides a set of APIs for creating and configuring Vite applications, supporting the building and development of standard applications and HTML applications. It emits native ESM module-federation artifacts consumed by @esmx/core, and provides real module-level HMR in development through Vite's dev server.
Installation
Use package manager to install @esmx/vite as a development dependency:
Type Exports
BuildTarget
Build target environment type that defines the application's build target environment:
node: Build code to run in Node.js environmentclient: Build code to run in browser environmentserver: Build code to run in server environment
ViteAppConfigContext
Vite application configuration context interface, provides context information accessible in the configuration hook function:
esmx: Esmx framework instancebuildTarget: Current build target (client/server/node)config: ViteInlineConfigobject — mutate it to customize the build (e.g. add a framework plugin)options: Application configuration options
ViteAppOptions
Vite application configuration options interface:
minimize: Whether to enable code minification;trueto enable,falseto disable,undefinedto automatically decide based on environment (enabled in production, disabled in development)config: Configuration hook function called for each build target before the build starts, used to mutate the resolved Vite configuration. It also applies to the development server.
ViteHtmlAppOptions
Options for a no-framework HTML application. Vite natively handles TypeScript, CSS and static assets, so unlike the Rspack equivalent no extra loader options are exposed.
Function Exports
createViteApp
Create a standard Vite application instance.
Parameters:
esmx— Esmx framework instanceoptions— Vite application configuration options
Returns:
- Returns a
Promisethat resolves to the created application instance
createViteHtmlApp
Create an HTML-type Vite application instance (no UI framework).
Parameters:
esmx— Esmx framework instanceoptions— HTML application configuration options
Returns:
- Returns a
Promisethat resolves to the created HTML application instance
Module Exports
vite
Re-exports all contents from the vite package, providing complete Vite core functionality.