Skip to content

Commit 4847a1e

Browse files
authored
build: enable source map (bangumi#244)
1 parent 9183606 commit 4847a1e

File tree

20 files changed

+41
-48
lines changed

20 files changed

+41
-48
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ dist-ssr
77
.idea
88
.pnpm-debug.log
99

10-
coverage
10+
coverage
11+
.eslintcache

packages/design/.storybook/main.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { dirname } from 'path';
22

33
import type { StorybookViteConfig } from '@storybook/builder-vite';
4-
import type { PluginOption } from 'vite';
54
import svgr from 'vite-plugin-svgr';
65

76
const config: StorybookViteConfig = {
@@ -13,6 +12,12 @@ const config: StorybookViteConfig = {
1312
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
1413
framework: '@storybook/react',
1514
viteFinal: (viteConfig) => {
15+
if (!viteConfig.build) {
16+
viteConfig.build = { sourcemap: true };
17+
} else {
18+
viteConfig.build.sourcemap = true;
19+
}
20+
1621
// workaround for vite build
1722
// Refs: https://github.com/eirslett/storybook-builder-vite/issues/55#issuecomment-871800293
1823
viteConfig.root = dirname(require.resolve('@storybook/builder-vite'));
@@ -22,18 +27,7 @@ const config: StorybookViteConfig = {
2227
* https://github.com/styleguidist/react-docgen-typescript/issues/323
2328
* https://github.com/styleguidist/react-docgen-typescript/issues/393
2429
* */
25-
!viteConfig.plugins && (viteConfig.plugins = []);
26-
/* WIP: Temporary patch for style */
27-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
28-
viteConfig.plugins.push({
29-
transform(source, id) {
30-
if (id.endsWith('.stories.tsx') && id.includes('components')) {
31-
return `${source}
32-
import './style'`;
33-
}
34-
return source;
35-
},
36-
} as PluginOption);
30+
viteConfig.plugins ??= [];
3731

3832
viteConfig.plugins.push(svgr());
3933
return viteConfig;

packages/design/components/Avatar/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classNames from 'classnames';
24
import type { FC } from 'react';
35
import React from 'react';

packages/design/components/Button/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classNames from 'classnames';
24
import type { FC, PropsWithChildren } from 'react';
35
import React from 'react';

packages/design/components/Divider/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import type { FC } from 'react';
35
import React from 'react';

packages/design/components/EditorForm/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import type { FC } from 'react';
35
import React, { useRef } from 'react';

packages/design/components/Image/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import type { FC, ImgHTMLAttributes } from 'react';
35
import React from 'react';

packages/design/components/Input/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import React, { forwardRef } from 'react';
35

packages/design/components/Layout/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import type { FC } from 'react';
35
import React from 'react';

packages/design/components/Menu/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './style';
2+
13
import classnames from 'classnames';
24
import type { FC } from 'react';
35
import React, { createContext, useContext } from 'react';

0 commit comments

Comments
 (0)