File tree Expand file tree Collapse file tree 8 files changed +435
-68
lines changed
examples/vue-component-bundle Expand file tree Collapse file tree 8 files changed +435
-68
lines changed Original file line number Diff line number Diff line change 1+ # @examples/vue-component
2+
3+ This example demonstrates how to use Rslib to build a simple Vue component.
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @examples/vue-component-bundle" ,
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+ "@rsbuild/plugin-vue" : " ^1.0.5" ,
13+ "@rslib/core" : " workspace:*" ,
14+ "typescript" : " ^5.6.3" ,
15+ "vue" : " ^3.5.13" ,
16+ "vue-tsc" : " ^2.1.10"
17+ },
18+ "peerDependencies" : {
19+ "vue" : " >=3.0.0"
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ import { pluginVue } from '@rsbuild/plugin-vue' ;
2+ import { defineConfig } from '@rslib/core' ;
3+
4+ export default defineConfig ( {
5+ plugins : [ pluginVue ( ) ] ,
6+ lib : [
7+ {
8+ format : 'esm' ,
9+ output : {
10+ distPath : {
11+ css : '.' ,
12+ } ,
13+ } ,
14+ } ,
15+ ] ,
16+ output : {
17+ target : 'web' ,
18+ } ,
19+ } ) ;
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 1+ import Counter from './Counter.vue' ;
2+
3+ export { Counter } ;
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments