Skip to content

Commit

Permalink
chore(examples): add vue-component-bundle example (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Nov 21, 2024
1 parent db602d2 commit 39ba4d9
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 68 deletions.
3 changes: 3 additions & 0 deletions examples/vue-component-bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @examples/vue-component

This example demonstrates how to use Rslib to build a simple Vue component.
21 changes: 21 additions & 0 deletions examples/vue-component-bundle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@examples/vue-component-bundle",
"private": true,
"type": "module",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "rslib build && vue-tsc"
},
"devDependencies": {
"@rsbuild/plugin-vue": "^1.0.5",
"@rslib/core": "workspace:*",
"typescript": "^5.6.3",
"vue": "^3.5.13",
"vue-tsc": "^2.1.10"
},
"peerDependencies": {
"vue": ">=3.0.0"
}
}
19 changes: 19 additions & 0 deletions examples/vue-component-bundle/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { pluginVue } from '@rsbuild/plugin-vue';
import { defineConfig } from '@rslib/core';

export default defineConfig({
plugins: [pluginVue()],
lib: [
{
format: 'esm',
output: {
distPath: {
css: '.',
},
},
},
],
output: {
target: 'web',
},
});
23 changes: 23 additions & 0 deletions examples/vue-component-bundle/src/Counter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div>
<h2 class="counter-text">Counter: {{ count }}</h2>
<counter-button @click="decrement" label="-" />
<counter-button @click="increment" label="+" />
</div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import CounterButton from './CounterButton.vue';
const count = ref(0);
const increment = () => count.value++;
const decrement = () => count.value--;
</script>

<style scoped>
.counter-text {
font-size: 50px;
}
</style>
16 changes: 16 additions & 0 deletions examples/vue-component-bundle/src/CounterButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<button type="button" @click="onClick">{{ label }}</button>
</template>

<script setup lang="ts">
defineProps<{
label: string;
onClick: () => void;
}>();
</script>

<style scoped>
.button {
background: yellow;
}
</style>
3 changes: 3 additions & 0 deletions examples/vue-component-bundle/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Counter from './Counter.vue';

export { Counter };
20 changes: 20 additions & 0 deletions examples/vue-component-bundle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"outDir": "dist",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"resolveJsonModule": true,
"rootDir": "src",
"skipLibCheck": true,
"strict": true
},
"exclude": ["**/node_modules"],
"include": ["src"]
}
Loading

0 comments on commit 39ba4d9

Please sign in to comment.