@vyriy/storybook-config 0.5.0 → 0.5.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/README.md +1 -0
- package/main.js +25 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ yarn add -D @vyriy/storybook-config storybook
|
|
|
29
29
|
Install `storybook` in the consumer project so CLI commands are available.
|
|
30
30
|
|
|
31
31
|
The shared style rule is reused from `@vyriy/webpack-config`, so consumers do not need local style loader dependencies for the default setup.
|
|
32
|
+
The config also replaces Storybook's built-in CSS rule with the shared CSS/PostCSS/Sass pipeline, so project configs should not need to remove Storybook CSS rules locally.
|
|
32
33
|
|
|
33
34
|
## Usage
|
|
34
35
|
|
package/main.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { style } from '@vyriy/webpack-config/rules.js';
|
|
2
|
+
const STYLE_FIXTURES = [
|
|
3
|
+
'style.css',
|
|
4
|
+
'style.scss',
|
|
5
|
+
'style.sass',
|
|
6
|
+
];
|
|
7
|
+
const isStyleCondition = (condition) => {
|
|
8
|
+
if (condition instanceof RegExp) {
|
|
9
|
+
return STYLE_FIXTURES.some((fixture) => condition.test(fixture));
|
|
10
|
+
}
|
|
11
|
+
if (typeof condition === 'string') {
|
|
12
|
+
return [
|
|
13
|
+
'.css',
|
|
14
|
+
'.scss',
|
|
15
|
+
'.sass',
|
|
16
|
+
].some((extension) => condition.includes(extension));
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
const isStyleRule = (rule) => {
|
|
21
|
+
if (!rule || typeof rule !== 'object' || Array.isArray(rule)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return isStyleCondition(rule.test);
|
|
25
|
+
};
|
|
2
26
|
const config = {
|
|
3
27
|
addons: [
|
|
4
28
|
'@storybook/addon-webpack5-compiler-swc',
|
|
@@ -29,7 +53,7 @@ const config = {
|
|
|
29
53
|
module: {
|
|
30
54
|
...webpackConfig.module,
|
|
31
55
|
rules: [
|
|
32
|
-
...(webpackConfig.module?.rules ?? []),
|
|
56
|
+
...(webpackConfig.module?.rules ?? []).filter((rule) => !isStyleRule(rule)),
|
|
33
57
|
style({ mode: 'inject' }),
|
|
34
58
|
],
|
|
35
59
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyriy/storybook-config",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Shared Storybook config for Vyriy projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./main.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@storybook/addon-webpack5-compiler-swc": "^4.0.3",
|
|
13
13
|
"@storybook/react-webpack5": "^10.4.1",
|
|
14
14
|
"@vueless/storybook-dark-mode": "^10.0.8",
|
|
15
|
-
"@vyriy/webpack-config": "0.5.
|
|
15
|
+
"@vyriy/webpack-config": "0.5.2",
|
|
16
16
|
"css-loader": "^7.1.4",
|
|
17
17
|
"mermaid": "^11.15.0",
|
|
18
18
|
"react": "^19.2.6",
|