-
-
Notifications
You must be signed in to change notification settings - Fork 57
feat: support Vue with unplugin-vue #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ea1f4fc
feat: support Vue with unplugin-vue
fi3ework 82c2dce
up
fi3ework 6654b3a
up
fi3ework b2d073e
up
fi3ework aac9125
Update website/docs/en/config/rsbuild/plugins.mdx
fi3ework 9ca9e3b
Update website/docs/en/guide/solution/vue.mdx
fi3ework 147390a
Update website/docs/zh/guide/solution/vue.mdx
fi3ework c099e27
up
fi3ework File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| # @examples/vue-component | ||
|
|
||
| This example demonstrates how to use Rslib to build a simple Vue component. | ||
| This example demonstrates how to use Rslib to build a simple bundled Vue component. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,25 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "allowJs": true, | ||
| "baseUrl": ".", | ||
| "lib": ["DOM", "ES2020"], | ||
| "jsx": "preserve", | ||
| "target": "ES2020", | ||
| "skipLibCheck": true, | ||
| "jsxImportSource": "vue", | ||
| "useDefineForClassFields": true, | ||
| "outDir": "dist", | ||
| "declaration": true, | ||
| "emitDeclarationOnly": true, | ||
| "esModuleInterop": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
|
|
||
| /* modules */ | ||
| "module": "ESNext", | ||
| "isolatedModules": true, | ||
| "outDir": "dist", | ||
| "lib": ["DOM", "ESNext"], | ||
| "moduleResolution": "node", | ||
| "resolveJsonModule": true, | ||
| "rootDir": "src", | ||
| "skipLibCheck": true, | ||
| "strict": true | ||
| "moduleResolution": "bundler", | ||
|
|
||
| /* type checking */ | ||
| "strict": true, | ||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true | ||
| }, | ||
| "exclude": ["**/node_modules"], | ||
| "include": ["src"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { createRequire } from 'node:module'; | ||
| import { dirname, join } from 'node:path'; | ||
| import type { StorybookConfig } from 'storybook-vue3-rsbuild'; | ||
| const require = createRequire(import.meta.url); | ||
|
|
||
| /** | ||
| * This function is used to resolve the absolute path of a package. | ||
| * It is needed in projects that use Yarn PnP or are set up within a monorepo. | ||
| */ | ||
| function getAbsolutePath(value: string): any { | ||
| return dirname(require.resolve(join(value, 'package.json'))); | ||
| } | ||
|
|
||
| const config: StorybookConfig = { | ||
| stories: [ | ||
| '../stories/**/*.mdx', | ||
| '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)', | ||
| ], | ||
| addons: [ | ||
| '@storybook/addon-onboarding', | ||
| '@storybook/addon-links', | ||
| '@storybook/addon-essentials', | ||
| '@storybook/addon-interactions', | ||
| { | ||
| name: getAbsolutePath('storybook-addon-rslib'), | ||
fi3ework marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| ], | ||
| framework: { | ||
| name: getAbsolutePath('storybook-vue3-rsbuild'), | ||
| options: {}, | ||
| }, | ||
| docs: { | ||
| autodocs: 'tag', | ||
| }, | ||
| typescript: { | ||
| check: true, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { Preview } from '@storybook/vue3'; | ||
|
|
||
| const preview: Preview = { | ||
| parameters: { | ||
| controls: { | ||
| matchers: { | ||
| color: /(background|color)$/i, | ||
| date: /Date$/i, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export default preview; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 bundleless Vue component. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "name": "@examples/vue-component-bundleless", | ||
| "private": true, | ||
| "type": "module", | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "scripts": { | ||
| "build": "rslib build && vue-tsc", | ||
| "build:storybook": "storybook build", | ||
| "dev": "rslib build --watch", | ||
| "storybook": "storybook dev", | ||
| "test": "vitest run" | ||
| }, | ||
| "devDependencies": { | ||
| "@rslib/core": "workspace:*", | ||
| "@storybook/addon-essentials": "^8.6.14", | ||
| "@storybook/addon-interactions": "^8.6.14", | ||
| "@storybook/addon-links": "^8.6.14", | ||
| "@storybook/addon-onboarding": "^8.6.14", | ||
| "@storybook/blocks": "^8.6.14", | ||
| "@storybook/test": "^8.6.14", | ||
| "@storybook/vue3": "^8.6.14", | ||
| "rsbuild-plugin-unplugin-vue": "^0.1.0", | ||
| "storybook": "^8.6.14", | ||
| "storybook-addon-rslib": "^1.0.1", | ||
| "storybook-vue3-rsbuild": "^1.0.1", | ||
| "typescript": "^5.8.3", | ||
| "vue": "^3.5.14", | ||
| "vue-tsc": "^2.2.10" | ||
| }, | ||
| "peerDependencies": { | ||
| "vue": ">=3.0.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from '@rslib/core'; | ||
| import { pluginUnpluginVue } from 'rsbuild-plugin-unplugin-vue'; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [pluginUnpluginVue()], | ||
| lib: [{ bundle: false, format: 'esm' }], | ||
| output: { | ||
| target: 'web', | ||
| }, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import Counter from './Counter.vue'; | ||
|
|
||
| export { Counter }; |
32 changes: 32 additions & 0 deletions
32
examples/vue-component-bundleless/stories/Button.stories.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { fn } from '@storybook/test'; | ||
| import type { Meta, StoryObj } from '@storybook/vue3'; | ||
| import Counter from '../dist/Counter'; | ||
|
|
||
| // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export | ||
| const meta = { | ||
| title: 'Example/Counter', | ||
| component: Counter, | ||
| parameters: { | ||
| // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout | ||
| layout: 'centered', | ||
| }, | ||
| // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
| tags: ['autodocs'], | ||
| // More on argTypes: https://storybook.js.org/docs/api/argtypes | ||
| argTypes: { | ||
| backgroundColor: { control: 'color' }, | ||
| }, | ||
| // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args | ||
| args: { onClick: fn() }, | ||
| } satisfies Meta<typeof Counter>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
| export const Primary: Story = { | ||
| args: { | ||
| primary: true, | ||
| label: 'Counter', | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "lib": ["DOM", "ES2020"], | ||
| "jsx": "preserve", | ||
| "target": "ES2020", | ||
| "skipLibCheck": true, | ||
| "jsxImportSource": "vue", | ||
| "useDefineForClassFields": true, | ||
| "outDir": "dist", | ||
| "declaration": true, | ||
| "emitDeclarationOnly": true, | ||
|
|
||
| /* modules */ | ||
| "module": "ESNext", | ||
| "isolatedModules": true, | ||
| "resolveJsonModule": true, | ||
| "moduleResolution": "bundler", | ||
|
|
||
| /* type checking */ | ||
| "strict": true, | ||
| "noUnusedLocals": true, | ||
| "noUnusedParameters": true | ||
| }, | ||
| "include": ["src"] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.