Skip to content

Commit 10086ff

Browse files
committed
UPDATE/Storybook configuration with 2 stories added
1 parent 0f0e2af commit 10086ff

24 files changed

+19456
-8875
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ node_modules
44
.cache
55
dist
66
.parcel-cache
7-
.yalc
7+
.yalc
8+
*storybook.log

.storybook/main.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { StorybookConfig } from '@storybook/react-webpack5';
2+
import type { WebpackConfiguration } from '@storybook/core-webpack';
3+
4+
const config: StorybookConfig = {
5+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
6+
addons: [
7+
'@storybook/addon-webpack5-compiler-swc',
8+
'@storybook/addon-onboarding',
9+
'@storybook/addon-links',
10+
'@storybook/addon-essentials',
11+
'@storybook/addon-interactions',
12+
'@storybook/addon-styling-webpack',
13+
'@storybook/preset-scss'
14+
],
15+
framework: {
16+
name: '@storybook/react-webpack5',
17+
options: {
18+
strictMode: true,
19+
},
20+
},
21+
webpackFinal: async (currentConfig: WebpackConfiguration, { configType }) => {
22+
// get index of css rule
23+
const ruleCssIndex = currentConfig.module.rules.findIndex(
24+
(rule) => rule.test?.toString() === "/\\.css$/"
25+
);
26+
27+
// map over the 'use' array of the css rule and set the 'module' option to true
28+
currentConfig.module.rules[ruleCssIndex].use.map((item) => {
29+
if (item.loader && item.loader.includes("/css-loader/")) {
30+
item.options.modules = {
31+
mode: "local",
32+
localIdentName:
33+
configType === "PRODUCTION"
34+
? "[local]__[hash:base64:5]"
35+
: "[name]__[local]__[hash:base64:5]",
36+
};
37+
}
38+
39+
return item;
40+
});
41+
42+
return currentConfig;
43+
},
44+
};
45+
export default config;

.storybook/preview.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Preview } from '@storybook/react';
2+
3+
const preview: Preview = {
4+
parameters: {
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/i,
9+
},
10+
},
11+
},
12+
tags: ['autodocs']
13+
};
14+
15+
export default preview;

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ To run tests, use `npm test` or `yarn test`.
9595

9696
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
9797

98+
### Storybook commands
99+
100+
```bash
101+
npm run storybook
102+
```
103+
104+
```bash
105+
npm run build-storybook
106+
```
107+
98108
### Jest
99109

100110
Jest tests are set up to run with `npm test` or `yarn test`.

0 commit comments

Comments
 (0)