Currently, Vue3 is supported by Rspack. Please make sure your vue-loader version is >= 17.2.2 and configure as follows:
rspack.config.js
const{ VueLoaderPlugin }=require('vue-loader');/** @type {import('@rspack/cli').Configuration} */const config ={// ...plugins:[newVueLoaderPlugin()],module:{rules:[// ...{test:/\.vue$/,loader:'vue-loader',options:{// Note, for the majority of features to be available, make sure this option is `true`experimentalInlineMatchResource:true,},},],},};module.exports = config;
As Rspack natively supports the compilation of CSS modules, you do not need to configure loaders related to CSS. In addition, when you try to use a CSS preprocessor (such as: less), you only need to add the following configuration:
At this time, Rspack will use the built-in CSS processor for post-processing.
If you don't want to generate CSS files, you can also use a combination of css-loader and vue-style-loader:
const config ={module:{rules:[{test:/\.less$/,use:['vue-style-loader','css-loader','less-loader'],type:'javascript/auto',},],},experiments:{css:false,// At this point, you need to turn off `experiments.css` to adapt to the internal processing logic of `vue-loader`},};module.exports = config;
Besides, as Rspack has built-in TS support, we also support lang="ts" configuration by default:
<scriptlang="ts">exportdefault{// ...};</script>
You can refer to the related example example-vue3.
Rspack has completed compatibility with Vue2 (using vue-loader@15).
Please make sure to turn off experiments.css when configuring Vue2 projects or use Rule.type = "javascript/auto" in CSS-related rules:
rspack.config.js
module.exports ={module:{rules:[{test:/\.css$/,use:['vue-style-loader','css-loader'],type:'javascript/auto',},{test:/\.ts$/,// add this rule when you use typescript in Vue SFCloader:'builtin:swc-loader',options:{sourceMap:true,jsc:{parser:{syntax:'typescript',},},},type:'javascript/auto',},],},experiments:{css:false,},};
TypeScript is supported using Rspack's native builtin:swc-loader, see this for details.