Vue plugin
The Vue plugin provides support for Vue 3 SFC (Single File Components). The plugin internally integrates vue-loader v17.
For Vue 3 JSX / TSX syntax, please use the Vue JSX plugin.
Quick start
Install plugin
Install the plugin with this command:
Register plugin
Register the plugin in your rsbuild.config.ts file:
After registering the plugin, you can import *.vue SFC files in your code.
Options
Customize Vue compilation behavior with these options:
vueLoaderOptions
Options passed to vue-loader. See the vue-loader documentation for detailed usage.
- Type:
VueLoaderOptions - Default:
- Example:
splitChunks
When chunkSplit.strategy set to split-by-experience, Rsbuild will automatically split vue and router related packages into separate chunks by default:
lib-vue.js: includesvue,vue-loader, and their sub-dependencies (@vue/shared,@vue/reactivity,@vue/runtime-dom,@vue/runtime-core).lib-router.js: includesvue-router.
This option is used to control this behavior and determine whether the vue and router related packages need to be split into separate chunks.
- Type:
- Default:
- Example:
test
Customize the matching rule for Vue Single File Components (SFC).
- Type: Rspack.RuleSetCondition
- Default:
/\.vue$/ - Version:
>= 1.2.1
This option allows you to extend the Vue plugin to handle additional file types. For example, you can first use a plugin or loader to transform .md files into Vue components, then configure the test option in the Vue plugin to match both .vue and .md files:
FAQ
/deep/ selector causes compilation error
/deep/ is a deprecated usage as of Vue v2.7. Since it is not a valid CSS syntax, CSS compilation tools like Lightning CSS will fail to compile it.
You can use :deep() instead. See Vue - Deep Selectors for more details.
You can also refer to Vue - RFC 0023 for more details.

