diff --git a/.storybook/main.ts b/.storybook/main.ts index 811a74d66b..d77226d059 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -1,6 +1,7 @@ import { resolve, dirname, join } from 'path'; import { mergeConfig } from 'vite'; import type { StorybookViteConfig } from '@storybook/builder-vite'; +import markdownRawPlugin from 'vite-raw-plugin'; const config: StorybookViteConfig = { stories: ['../packages/**/*.stories.mdx', '../packages/**/*.stories.@(ts|tsx)'], @@ -23,6 +24,11 @@ const config: StorybookViteConfig = { async viteFinal(config) { // Merge custom configuration into the default config return mergeConfig(config, { + plugins: [ + markdownRawPlugin({ + fileRegex: /\.md$/, + }), + ], css: { postcss: resolve(__dirname, 'config'), preprocessorOptions: { diff --git a/package.json b/package.json index d42346d4e0..aec567c6eb 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "storybook": "7.3.2", "style-loader": "3.3.3", "typescript": "4.7.4", + "vite-raw-plugin": "^1.0.2", "webpack": "5.88.2", "webpack-cli": "5.1.4" }, diff --git a/packages/web-react/.eslintrc.js b/packages/web-react/.eslintrc.js index 6c75c782de..a6ff9cf140 100644 --- a/packages/web-react/.eslintrc.js +++ b/packages/web-react/.eslintrc.js @@ -25,7 +25,7 @@ module.exports = { settings: { 'import/resolver': { node: { - extensions: ['.js', '.jsx', '.ts', '.tsx', '.md', 'raw', '.md?raw'], + extensions: ['.js', '.jsx', '.ts', '.tsx', '.md'], }, }, }, @@ -63,15 +63,6 @@ module.exports = { 'no-param-reassign': ['warn', { props: false }], // support monorepos 'import/no-extraneous-dependencies': ['error', { packageDir: ['./', '../../'] }], - 'import/no-unresolved': [ - 2, - { - ignore: [ - // Ignore vite's ?raw imports - '.*?raw', - ], - }, - ], // disable double quotes quotes: ['warn', 'single'], }, diff --git a/packages/web-react/src/components/Button/Button.stories.tsx b/packages/web-react/src/components/Button/Button.stories.tsx index 1529b3f3d6..b36a5b2d93 100644 --- a/packages/web-react/src/components/Button/Button.stories.tsx +++ b/packages/web-react/src/components/Button/Button.stories.tsx @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { Button } from './Button'; import { args, argTypes } from './stories/args'; -import ReadMe from './README.md?raw'; +import ReadMe from './README.md'; const meta: Meta = { title: 'Components/Button', diff --git a/packages/web-react/src/components/Button/ButtonLink.stories.tsx b/packages/web-react/src/components/Button/ButtonLink.stories.tsx index 78a14a2523..fa1a1d09fc 100644 --- a/packages/web-react/src/components/Button/ButtonLink.stories.tsx +++ b/packages/web-react/src/components/Button/ButtonLink.stories.tsx @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { ButtonLink } from './ButtonLink'; import { args, argTypes } from './stories/args'; -import ReadMe from './README.md?raw'; +import ReadMe from './README.md'; const meta: Meta = { title: 'Components/ButtonLink', diff --git a/packages/web-react/src/components/Modal/Modal.stories.tsx b/packages/web-react/src/components/Modal/Modal.stories.tsx index d93990b0f8..45052b19b9 100644 --- a/packages/web-react/src/components/Modal/Modal.stories.tsx +++ b/packages/web-react/src/components/Modal/Modal.stories.tsx @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { SpiritModalProps } from '../../types'; import { Button } from '../Button'; -import ReadMe from './README.md?raw'; +import ReadMe from './README.md'; import { Modal, ModalHeader, ModalDialog, ModalBody, ModalFooter } from '.'; const meta: Meta = { diff --git a/packages/web-react/src/components/Pill/Pill.stories.tsx b/packages/web-react/src/components/Pill/Pill.stories.tsx index fae574944d..e83825ec79 100644 --- a/packages/web-react/src/components/Pill/Pill.stories.tsx +++ b/packages/web-react/src/components/Pill/Pill.stories.tsx @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'; import { ActionColors, EmotionColors } from '../../constants'; import { Pill } from './Pill'; -import ReadMe from './README.md?raw'; +import ReadMe from './README.md'; const meta: Meta = { title: 'Components/Pill', diff --git a/packages/web-react/src/global.d.ts b/packages/web-react/src/global.d.ts index 80d2786c9c..c45dcd0e4e 100644 --- a/packages/web-react/src/global.d.ts +++ b/packages/web-react/src/global.d.ts @@ -1,4 +1,4 @@ -declare module '*.md?raw' { +declare module '*.md' { const content: string; export default content; } diff --git a/yarn.lock b/yarn.lock index fe7166a21c..7a958ad64e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23738,6 +23738,11 @@ vite-plugin-handlebars@1.6.0: handlebars "^4.7.6" vite "^2.0.0" +vite-raw-plugin@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/vite-raw-plugin/-/vite-raw-plugin-1.0.2.tgz#7be8a6e1275b7a0eb6753d066337957c15f438cd" + integrity sha512-gdp/OFVXBiVq1UwPujVb7+4mmgYHTGrzslMbQvxmgzTN4/HC+3j4GNrumsIKSWfA/y3hktII7XqY38muRaGjhw== + vite@4.4.9: version "4.4.9" resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.9.tgz#1402423f1a2f8d66fd8d15e351127c7236d29d3d"