English
Rspack
Rspack bundler is provided by @vuepress/bundler-rspack package.
Usage
Install the bundler package:
npm i -D @vuepress/bundler-rspack@nextSpecify the bundler option in your config file:
import { rspackBundler } from '@vuepress/bundler-rspack'
import { defineUserConfig } from 'vuepress'
export default defineUserConfig({
bundler: rspackBundler({
postcss: {},
vue: {},
}),
})Tips
There is no vuepress-rspack CLI shorthand. Unlike the vuepress-vite and vuepress-webpack commands, you always need to select the bundler with bundler: rspackBundler() in your config file.
Exports
rspackBundler
Type:
(options?: RspackBundlerOptions) => BundlerDetails:
Create a rspack bundler instance.
rspackMergeConfig
Type:
(configA: RspackConfiguration, configB: RspackConfiguration) => RspackConfigurationDetails:
Merge two rspack config objects, provided by rspack-merge.
Exported types
The package re-exports the types of its options and the underlying tools:
RspackBundlerOptionsRspackConfiguration(from@rspack/core)RspackDevServer(from@rspack/dev-server)VueLoaderOptions,PostcssLoaderOptions,StylusLoaderOptions,SassLoaderOptions,LessLoaderOptions
Options
configureRspack
Type:
(config: RspackConfiguration, isServer: boolean, isBuild: boolean) => RspackConfiguration | voidDetails:
Edit the internal rspack config.
This option accepts a function that will receive a rspack config object as the 1st argument, an
isServerflag as the 2nd argument and anisBuildflag as the 3rd argument. You can either mutate the config directly, or return an object to replace the rspack config object.
chainRspack
Type:
(config: RspackChain, isServer: boolean, isBuild: boolean) => voidDetails:
Edit the internal rspack config with rspack-chain.
This option accepts a function that will receive a
Configinstance that provided byrspack-chainas the 1st argument, anisServerflag as the 2nd argument and anisBuildflag as the 3rd argument.
devServerSetupMiddlewares
Type:
RspackDevServerConfiguration['setupMiddlewares']Details:
A hook to be called in
devServer.setupMiddlewaresof @rspack/dev-server.The arguments of the function are those of
devServer.setupMiddlewares. You can import theRspackDevServerConfigurationtype from@rspack/dev-serverif you need to type the hook yourself.Also see:
vue
Type:
VueLoaderOptionsDetails:
Options for
vue-loader.Also see:
postcss
Type:
PostcssLoaderOptionsDetails:
Options for
postcss-loader.Also see:
stylus
Type:
StylusLoaderOptionsDetails:
Options for
stylus-loader.Also see:
scss
Type:
SassLoaderOptionsDetails:
Options for
sass-loaderfor.scssfiles.Also see:
sass
Type:
SassLoaderOptionsDetails:
Options for
sass-loaderfor.sassfiles.Also see:
less
Type:
LessLoaderOptionsDetails:
Options for
less-loader.Also see:
evergreen
Type:
booleanDefault:
trueDetails:
Set to
trueif you are only targeting evergreen browsers. This will disable some transpilation and polyfills, and result in faster builds and smaller files.
FAQ
Using with SASS-based Themes
The default theme uses plain CSS, so it does not require any SASS setup. If you use a theme that relies on SASS as CSS pre-processor — for example, the classic theme (@vuepress/theme-classic) — you might need to install sass-loader as a peer dependency to make it work with Webpack (and Rspack), especially when you are using pnpm.
