Skip to content

Commit f64e62d

Browse files
committed
feat: support Vue with unplugin-vue
1 parent 06bd7cf commit f64e62d

File tree

21 files changed

+571
-693
lines changed

21 files changed

+571
-693
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# @examples/vue-component
22

3-
This example demonstrates how to use Rslib to build a simple Vue component.
3+
This example demonstrates how to use Rslib to build a simple bundled Vue component.

examples/vue-component-bundle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"build": "rslib build && vue-tsc"
1010
},
1111
"devDependencies": {
12-
"@rsbuild/plugin-vue": "^1.0.7",
1312
"@rslib/core": "workspace:*",
13+
"rsbuild-plugin-unplugin-vue": "^0.0.3",
1414
"typescript": "^5.8.3",
1515
"vue": "^3.5.13",
1616
"vue-tsc": "^2.2.10"
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { pluginVue } from '@rsbuild/plugin-vue';
21
import { defineConfig } from '@rslib/core';
2+
import { pluginUnpluginVue } from 'rsbuild-plugin-unplugin-vue';
33

44
export default defineConfig({
5-
plugins: [pluginVue()],
5+
plugins: [pluginUnpluginVue()],
66
lib: [{ format: 'esm' }],
7-
output: {
8-
target: 'web',
9-
},
107
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @examples/vue-component
2+
3+
This example demonstrates how to use Rslib to build a simple bundleless Vue component.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@examples/vue-component-bundleless",
3+
"private": true,
4+
"type": "module",
5+
"main": "./dist/index.js",
6+
"module": "./dist/index.js",
7+
"types": "./dist/index.d.ts",
8+
"scripts": {
9+
"build": "rslib build && vue-tsc"
10+
},
11+
"devDependencies": {
12+
"@rslib/core": "workspace:*",
13+
"rsbuild-plugin-unplugin-vue": "^0.0.3",
14+
"typescript": "^5.8.3",
15+
"vue": "^3.5.13",
16+
"vue-tsc": "^2.2.10"
17+
},
18+
"peerDependencies": {
19+
"vue": ">=3.0.0"
20+
}
21+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from '@rslib/core';
2+
import { pluginUnpluginVue } from 'rsbuild-plugin-unplugin-vue';
3+
4+
export default defineConfig({
5+
plugins: [pluginUnpluginVue()],
6+
lib: [{ bundle: false, format: 'esm' }],
7+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div>
3+
<h2 class="counter-text">Counter: {{ count }}</h2>
4+
<counter-button @click="decrement" label="-" />
5+
<counter-button @click="increment" label="+" />
6+
</div>
7+
</template>
8+
9+
<script setup lang="ts">
10+
import { ref } from 'vue';
11+
import CounterButton from './CounterButton.vue';
12+
13+
const count = ref(0);
14+
15+
const increment = () => count.value++;
16+
const decrement = () => count.value--;
17+
</script>
18+
19+
<style scoped>
20+
.counter-text {
21+
font-size: 50px;
22+
}
23+
</style>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<button type="button" @click="onClick">{{ label }}</button>
3+
</template>
4+
5+
<script setup lang="ts">
6+
defineProps<{
7+
label: string;
8+
onClick: () => void;
9+
}>();
10+
</script>
11+
12+
<style scoped>
13+
.button {
14+
background: yellow;
15+
}
16+
</style>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Counter from './Counter.vue';
2+
3+
export { Counter };
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"baseUrl": ".",
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"isolatedModules": true,
10+
"outDir": "dist",
11+
"lib": ["DOM", "ESNext"],
12+
"moduleResolution": "node",
13+
"resolveJsonModule": true,
14+
"rootDir": "src",
15+
"skipLibCheck": true,
16+
"strict": true
17+
},
18+
"exclude": ["**/node_modules"],
19+
"include": ["src"]
20+
}

0 commit comments

Comments
 (0)