@esmx/rspack-vue provides a set of APIs for creating and configuring Vue-based Rspack applications, supporting Vue 2.7+ and Vue 3 component development, building, and SSR.
Use package manager to install @esmx/rspack-vue as a development dependency:
npm install @esmx/rspack-vue vue -Dinterface RspackVueAppOptions extends RspackHtmlAppOptions {
vueLoader?: Record<string, any>
}Vue application configuration options interface, inherits from @esmx/rspack's RspackHtmlAppOptions:
vueLoader: vue-loader configuration optionsFor details on base types, please refer to the @esmx/rspack documentation.
function createRspackVue2App(esmx: Esmx, options?: RspackVueAppOptions): Promise<App>Creates a Vue 2.7+ application build instance. Automatically configures vue-loader-v15 and Vue 2 related compilation options.
Parameters:
esmx: Esmx framework instanceoptions: Vue application configuration optionsReturns:
Promise that resolves to the created application instancefunction createRspackVue3App(esmx: Esmx, options?: RspackVueAppOptions): Promise<App>Creates a Vue 3 application build instance. Automatically configures vue-loader-v17 and Vue 3 related compilation options.
Parameters:
esmx: Esmx framework instanceoptions: Vue application configuration optionsReturns:
Promise that resolves to the created application instanceconst RSPACK_LOADER: Record<string, string> = {
builtinSwcLoader: 'builtin:swc-loader',
lightningcssLoader: 'builtin:lightningcss-loader',
styleLoader: 'style-loader',
cssLoader: 'css-loader',
lessLoader: 'less-loader',
styleResourcesLoader: 'style-resources-loader',
workerRspackLoader: 'worker-rspack-loader'
}Rspack built-in loader identifier mapping object that provides commonly used loader name constants:
builtinSwcLoader: Rspack built-in SWC loader for processing TypeScript/JavaScript fileslightningcssLoader: Rspack built-in lightningcss loader, a high-performance compiler for processing CSS filesstyleLoader: Loader that injects CSS into the DOMcssLoader: Loader that parses CSS files and handles CSS modularizationlessLoader: Loader that compiles Less files to CSSstyleResourcesLoader: Loader that automatically imports global style resources (variables, mixins, etc.)workerRspackLoader: Loader for processing Web Worker filesUsing these constants can reference built-in loaders in configuration, avoiding manual string input:
import { RSPACK_LOADER } from '@esmx/rspack';
export default {
async devApp(esmx) {
return import('@esmx/rspack').then((m) =>
m.createRspackHtmlApp(esmx, {
loaders: {
// Use constants to reference loaders
styleLoader: RSPACK_LOADER.styleLoader,
cssLoader: RSPACK_LOADER.cssLoader,
lightningcssLoader: RSPACK_LOADER.lightningcssLoader
}
})
);
}
};Notes:
builtinSwcLoader) have specific configuration options; please refer to the corresponding configuration documentationRe-exports all contents from @rspack/core package, providing complete Rspack core functionality.