storybook-builder-rsbuild 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -150
- package/package.json +10 -3
- package/typings.d.ts +2 -2
- package/dist/presets/custom-rsbuild-preset.d.ts +0 -2
- package/dist/presets/preview-preset.d.ts +0 -2
package/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2024
|
3
|
+
Copyright (c) 2024 Rspack Contrib
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
@@ -1,152 +1,3 @@
|
|
1
1
|
# storybook-builder-rsbuild
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Requirements: `@rsbuild/core >= 0.6.15`, In Storybook v8, you don't need to manually install storybook-builder-rsbuild, it has been depended by the framework, such as storybook-react-rsbuild and storybook-vue3-rsbuild.
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
### Use with React
|
12
|
-
|
13
|
-
1. Install `storybook-react-rsbuild`.
|
14
|
-
2. Change `.storybook/main.js`
|
15
|
-
|
16
|
-
```js
|
17
|
-
import { StorybookConfig } from 'storybook-react-rsbuild'
|
18
|
-
|
19
|
-
const config: StorybookConfig = {
|
20
|
-
framework: 'storybook-react-rsbuild',
|
21
|
-
rsbuildFinal: (config) => {
|
22
|
-
// Customize the final webpack config here
|
23
|
-
return config;
|
24
|
-
},
|
25
|
-
};
|
26
|
-
|
27
|
-
export default config;
|
28
|
-
```
|
29
|
-
|
30
|
-
Now you're all set.
|
31
|
-
|
32
|
-
### Use with Vue3
|
33
|
-
|
34
|
-
1. Install `storybook-vue3-rsbuild`.
|
35
|
-
2. Change `.storybook/main.js`
|
36
|
-
|
37
|
-
```js
|
38
|
-
import { StorybookConfig } from 'storybook-vue3-rsbuild'
|
39
|
-
|
40
|
-
const config: StorybookConfig = {
|
41
|
-
framework: 'storybook-vue3-rsbuild',
|
42
|
-
rsbuildFinal: (config) => {
|
43
|
-
// Customize the final webpack config here
|
44
|
-
return config;
|
45
|
-
},
|
46
|
-
};
|
47
|
-
|
48
|
-
export default config;
|
49
|
-
```
|
50
|
-
|
51
|
-
Now you're all set.
|
52
|
-
|
53
|
-
### Customize the Rsbuild config
|
54
|
-
|
55
|
-
The builder _will_ read your `rsbuild.config.js` file, though it may change some of the options in order to work correctly.
|
56
|
-
It looks for the Rsbuild config in the CWD. If your config is located elsewhere, specify the path using the `rsbuildConfigPath` builder option:
|
57
|
-
|
58
|
-
```javascript
|
59
|
-
// .storybook/main.mjs
|
60
|
-
|
61
|
-
const config = {
|
62
|
-
framework: {
|
63
|
-
name: 'storybook-react-rsbuild',
|
64
|
-
options: {
|
65
|
-
builder: {
|
66
|
-
rsbuildConfigPath: '.storybook/customRsbuildConfig.js',
|
67
|
-
},
|
68
|
-
},
|
69
|
-
},
|
70
|
-
}
|
71
|
-
|
72
|
-
export default config
|
73
|
-
```
|
74
|
-
|
75
|
-
You can also override the merged Rsbuild config:
|
76
|
-
|
77
|
-
```javascript
|
78
|
-
// use `mergeRsbuildConfig` to recursively merge Rsbuild options
|
79
|
-
import { mergeRsbuildConfig } from '@rsbuild/core'
|
80
|
-
|
81
|
-
const config = {
|
82
|
-
async rsbuildFinal(config, { configType }) {
|
83
|
-
// Be sure to return the customized config
|
84
|
-
return mergeRsbuildConfig(config, {
|
85
|
-
// Customize the Rsbuild config for Storybook
|
86
|
-
source: {
|
87
|
-
alias: { foo: 'bar' },
|
88
|
-
},
|
89
|
-
})
|
90
|
-
},
|
91
|
-
}
|
92
|
-
|
93
|
-
export default config
|
94
|
-
```
|
95
|
-
|
96
|
-
The `rsbuildFinal` function will give you `config` which is the combination of your project's Rsbuild config and the builder's own Rsbuild config.
|
97
|
-
You can tweak this as you want, for example to set up aliases, add new plugins etc.
|
98
|
-
|
99
|
-
The `configType` variable will be either `"DEVELOPMENT"` or `"PRODUCTION"`.
|
100
|
-
|
101
|
-
The function should return the updated Rsbuild configuration.
|
102
|
-
|
103
|
-
## Troubleshooting
|
104
|
-
|
105
|
-
### Error caused by bundling unwanted modules
|
106
|
-
|
107
|
-
Because Rspack temporarily does not support the `webpackInclude` magic comment, non-story files may be bundled, which could lead to build failures. These files can be ignored using `rspack.IgnorePlugin`.
|
108
|
-
|
109
|
-
```js
|
110
|
-
import { mergeRsbuildConfig } from '@rsbuild/core'
|
111
|
-
|
112
|
-
module.exports = {
|
113
|
-
framework: 'storybook-react-rsbuild',
|
114
|
-
async rsbuildFinal(config) {
|
115
|
-
return mergeRsbuildConfig(config, {
|
116
|
-
tools: {
|
117
|
-
rspack: (config, { addRules, appendPlugins, rspack, mergeConfig }) => {
|
118
|
-
appendPlugins([
|
119
|
-
new rspack.IgnorePlugin({
|
120
|
-
checkResource: (resource, context) => {
|
121
|
-
const absPathHasExt = extname(resource)
|
122
|
-
if (absPathHasExt === '.md') {
|
123
|
-
return true
|
124
|
-
}
|
125
|
-
|
126
|
-
return false
|
127
|
-
},
|
128
|
-
}),
|
129
|
-
])
|
130
|
-
},
|
131
|
-
},
|
132
|
-
})
|
133
|
-
},
|
134
|
-
}
|
135
|
-
```
|
136
|
-
|
137
|
-
## Rspack support tasks
|
138
|
-
|
139
|
-
- [ ] Support persistent cache
|
140
|
-
- [ ] Support lazy compilation
|
141
|
-
- [ ] Support virtual modules
|
142
|
-
- [ ] Support `module.unknownContextCritical`
|
143
|
-
- [ ] Support `webpackInclude` magic comment
|
144
|
-
- [ ] Support `compilation.dependencyTemplates.set` for react-docgen-typescript
|
145
|
-
|
146
|
-
## Credits
|
147
|
-
|
148
|
-
Some codes are copied or modified from [storybookjs/storybook](https://github.com/storybookjs/storybook).
|
149
|
-
|
150
|
-
## License
|
151
|
-
|
152
|
-
[MIT](./LICENSE)
|
3
|
+
Check out [rspack-contrib/storybook-rsbuild](https://github.com/rspack-contrib/storybook-rsbuild) for documentation.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "storybook-builder-rsbuild",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.2",
|
4
4
|
"description": "Rsbuild builder for Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -8,6 +8,14 @@
|
|
8
8
|
"rspack"
|
9
9
|
],
|
10
10
|
"license": "MIT",
|
11
|
+
"bugs": {
|
12
|
+
"url": "https://github.com/rspack-contrib/storybook-rsbuild/issues"
|
13
|
+
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "https://github.com/rspack-contrib/storybook-rsbuild",
|
17
|
+
"directory": "packages/builder-rsbuild"
|
18
|
+
},
|
11
19
|
"exports": {
|
12
20
|
".": {
|
13
21
|
"types": "./dist/index.d.ts",
|
@@ -88,8 +96,7 @@
|
|
88
96
|
"typescript": "^5.3.2"
|
89
97
|
},
|
90
98
|
"peerDependencies": {
|
91
|
-
"@rsbuild/core": ">= 0.6.15"
|
92
|
-
"vite": "^4.0.0 || ^5.0.0"
|
99
|
+
"@rsbuild/core": ">= 0.6.15"
|
93
100
|
},
|
94
101
|
"peerDependenciesMeta": {
|
95
102
|
"typescript": {
|
package/typings.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
declare module 'lazy-universal-dotenv'
|
2
|
-
declare module '@storybook/theming/paths'
|
1
|
+
declare module 'lazy-universal-dotenv'
|
2
|
+
declare module '@storybook/theming/paths'
|