The Rspack package provides a set of APIs for creating and configuring Rspack applications, supporting the building and development of both standard applications and HTML applications.
Install @esmx/rspack as a development dependency using your package manager:
The build target environment type defines the target environment for application building, used to configure specific optimizations and features during the build process:
node: Builds code to run in Node.js environmentsclient: Builds code to run in browser environmentsserver: Builds code to run in server environmentsThe Rspack application configuration context interface provides contextual information accessible within configuration hook functions:
esmx: Esmx framework instancebuildTarget: Current build target (client/server/node)config: Rspack configuration objectoptions: Application configuration optionsRspack application configuration options interface:
css: CSS output method, either 'css' (standalone files) or 'js' (bundled into JS). Defaults to automatic selection based on environment: production uses 'css' for cache optimization and parallel loading, development uses 'js' to support HMRloaders: Custom loader configurationsstyleLoader: style-loader configuration optionscssLoader: css-loader configuration optionstarget: Build target compatibility configurationsdefinePlugin: Global constant definitionsconfig: Configuration hook functionExtends RspackAppOptions, used to configure HTML application-specific options.
Creates a standard Rspack application instance.
Parameters:
esmx: Esmx framework instanceoptions: Rspack application configuration optionsReturns:
Creates an HTML-type Rspack application instance.
Parameters:
esmx: Esmx framework instanceoptions: HTML application configuration optionsReturns:
A mapping object of Rspack's built-in loader identifiers, providing commonly used loader name constants:
builtinSwcLoader: Rspack's built-in SWC loader for processing TypeScript/JavaScript fileslightningcssLoader: Rspack's built-in lightningcss loader, a high-performance compiler for CSS filesstyleLoader: Loader for injecting CSS into the DOMcssLoader: Loader for parsing CSS files and handling CSS modularizationlessLoader: Loader for compiling Less files into CSSstyleResourcesLoader: Loader for automatically importing global style resources (e.g., variables, mixins)workerRspackLoader: Loader for processing Web Worker filesUsing these constants allows referencing built-in loaders in configurations, avoiding manual string input:
Notes:
builtinSwcLoader) have specific configuration options - refer to their respective documentationRe-exports all contents from the @rspack/core package, providing complete Rspack core functionality.