Skip to content

Commit 129d69e

Browse files
feat: support Vue with unplugin-vue (#995)
Co-authored-by: Timeless0911 <[email protected]>
1 parent cadbb64 commit 129d69e

File tree

35 files changed

+2347
-777
lines changed

35 files changed

+2347
-777
lines changed

cspell.config.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
'doc_build',
1818
'node_modules',
1919
'pnpm-lock.yaml',
20+
'tests/integration/vue/index.test.ts',
2021
],
2122
flagWords: banWords,
2223
dictionaries: ['dictionary'],
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.1.0",
1414
"typescript": "^5.8.3",
1515
"vue": "^3.5.14",
1616
"vue-tsc": "^2.2.10"

examples/vue-component-bundle/rslib.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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' }],
77
output: {
88
target: 'web',
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
{
22
"compilerOptions": {
3-
"allowJs": true,
4-
"baseUrl": ".",
3+
"lib": ["DOM", "ES2020"],
4+
"jsx": "preserve",
5+
"target": "ES2020",
6+
"skipLibCheck": true,
7+
"jsxImportSource": "vue",
8+
"useDefineForClassFields": true,
9+
"outDir": "dist",
510
"declaration": true,
611
"emitDeclarationOnly": true,
7-
"esModuleInterop": true,
8-
"forceConsistentCasingInFileNames": true,
12+
13+
/* modules */
14+
"module": "ESNext",
915
"isolatedModules": true,
10-
"outDir": "dist",
11-
"lib": ["DOM", "ESNext"],
12-
"moduleResolution": "node",
1316
"resolveJsonModule": true,
14-
"rootDir": "src",
15-
"skipLibCheck": true,
16-
"strict": true
17+
"moduleResolution": "bundler",
18+
19+
/* type checking */
20+
"strict": true,
21+
"noUnusedLocals": true,
22+
"noUnusedParameters": true
1723
},
18-
"exclude": ["**/node_modules"],
1924
"include": ["src"]
2025
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { createRequire } from 'node:module';
2+
import { dirname, join } from 'node:path';
3+
import type { StorybookConfig } from 'storybook-vue3-rsbuild';
4+
const require = createRequire(import.meta.url);
5+
6+
/**
7+
* This function is used to resolve the absolute path of a package.
8+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
9+
*/
10+
function getAbsolutePath(value: string): any {
11+
return dirname(require.resolve(join(value, 'package.json')));
12+
}
13+
14+
const config: StorybookConfig = {
15+
stories: [
16+
'../stories/**/*.mdx',
17+
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
18+
],
19+
addons: [
20+
'@storybook/addon-onboarding',
21+
'@storybook/addon-links',
22+
'@storybook/addon-essentials',
23+
'@storybook/addon-interactions',
24+
{
25+
name: getAbsolutePath('storybook-addon-rslib'),
26+
},
27+
],
28+
framework: {
29+
name: getAbsolutePath('storybook-vue3-rsbuild'),
30+
options: {},
31+
},
32+
docs: {
33+
autodocs: 'tag',
34+
},
35+
typescript: {
36+
check: true,
37+
},
38+
};
39+
40+
export default config;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Preview } from '@storybook/vue3';
2+
3+
const preview: Preview = {
4+
parameters: {
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/i,
9+
},
10+
},
11+
},
12+
};
13+
14+
export default preview;
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
"build:storybook": "storybook build",
11+
"dev": "rslib build --watch",
12+
"storybook": "storybook dev",
13+
"test": "vitest run"
14+
},
15+
"devDependencies": {
16+
"@rslib/core": "workspace:*",
17+
"@storybook/addon-essentials": "^8.6.14",
18+
"@storybook/addon-interactions": "^8.6.14",
19+
"@storybook/addon-links": "^8.6.14",
20+
"@storybook/addon-onboarding": "^8.6.14",
21+
"@storybook/blocks": "^8.6.14",
22+
"@storybook/test": "^8.6.14",
23+
"@storybook/vue3": "^8.6.14",
24+
"rsbuild-plugin-unplugin-vue": "^0.1.0",
25+
"storybook": "^8.6.14",
26+
"storybook-addon-rslib": "^1.0.1",
27+
"storybook-vue3-rsbuild": "^1.0.1",
28+
"typescript": "^5.8.3",
29+
"vue": "^3.5.14",
30+
"vue-tsc": "^2.2.10"
31+
},
32+
"peerDependencies": {
33+
"vue": ">=3.0.0"
34+
}
35+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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+
output: {
8+
target: 'web',
9+
},
10+
});

0 commit comments

Comments
 (0)