diff --git a/code/frameworks/react-vite/package.json b/code/frameworks/react-vite/package.json index 9dad100a57c3..1e78d5ecd97e 100644 --- a/code/frameworks/react-vite/package.json +++ b/code/frameworks/react-vite/package.json @@ -52,7 +52,7 @@ "@rollup/pluginutils": "^4.2.0", "@storybook/builder-vite": "7.0.0-beta.29", "@storybook/react": "7.0.0-beta.29", - "@vitejs/plugin-react": "^3.0.0", + "@vitejs/plugin-react": "^3.0.1", "ast-types": "^0.14.2", "magic-string": "^0.26.1", "react-docgen": "6.0.0-alpha.3" diff --git a/code/lib/builder-vite/package.json b/code/lib/builder-vite/package.json index 1456c587fac9..e2fe7c976553 100644 --- a/code/lib/builder-vite/package.json +++ b/code/lib/builder-vite/package.json @@ -43,6 +43,8 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { + "@storybook/channel-postmessage": "7.0.0-beta.29", + "@storybook/channel-websocket": "7.0.0-beta.29", "@storybook/client-logger": "7.0.0-beta.29", "@storybook/core-common": "7.0.0-beta.29", "@storybook/csf-plugin": "7.0.0-beta.29", @@ -67,7 +69,7 @@ "@types/node": "^16.0.0", "rollup": "^3.0.0", "typescript": "~4.9.3", - "vite": "^4.0.0" + "vite": "^4.0.4" }, "peerDependencies": { "@preact/preset-vite": "*", diff --git a/code/lib/builder-vite/src/vite-config.ts b/code/lib/builder-vite/src/vite-config.ts index c282601e59eb..316d970189a0 100644 --- a/code/lib/builder-vite/src/vite-config.ts +++ b/code/lib/builder-vite/src/vite-config.ts @@ -91,7 +91,7 @@ export async function pluginConfig(options: Options) { } }, }, - viteExternalsPlugin(globals, { useWindow: false }), + viteExternalsPlugin(globals, { useWindow: false, disableInServe: true }), ] as PluginOption[]; // TODO: framework doesn't exist, should move into framework when/if built diff --git a/code/ui/.storybook/main.ts b/code/ui/.storybook/main.ts index 52bb8b72192d..ca2f9534cf72 100644 --- a/code/ui/.storybook/main.ts +++ b/code/ui/.storybook/main.ts @@ -1,4 +1,6 @@ +import path from 'path'; import pluginTurbosnap from 'vite-plugin-turbosnap'; +import { mergeConfig } from 'vite'; import type { StorybookConfig } from '../../frameworks/react-vite'; const isBlocksOnly = process.env.STORYBOOK_BLOCKS_ONLY === 'true'; @@ -60,19 +62,24 @@ const config: StorybookConfig = { features: { interactionsDebugger: true, }, - viteFinal: (viteConfig, { configType }) => ({ - ...viteConfig, - plugins: [ - ...(viteConfig.plugins || []), - configType === 'PRODUCTION' ? pluginTurbosnap({ rootDir: viteConfig.root || '' }) : [], - ], - optimizeDeps: { ...viteConfig.optimizeDeps, force: true }, - build: { - ...viteConfig.build, - // disable sourcemaps in CI to not run out of memory - sourcemap: process.env.CI !== 'true', - }, - }), + viteFinal: (viteConfig, { configType }) => + mergeConfig(viteConfig, { + resolve: { + alias: { + ...(configType === 'DEVELOPMENT' + ? { '@storybook/components': path.resolve(__dirname, '../components/src') } + : {}), + }, + }, + plugins: [ + configType === 'PRODUCTION' ? pluginTurbosnap({ rootDir: viteConfig.root || '' }) : [], + ], + optimizeDeps: { force: true }, + build: { + // disable sourcemaps in CI to not run out of memory + sourcemap: process.env.CI !== 'true', + }, + }), }; export default config; diff --git a/code/yarn.lock b/code/yarn.lock index 21ab5d9d6a84..cbc78ea1d32b 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6062,6 +6062,8 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/builder-vite@workspace:lib/builder-vite" dependencies: + "@storybook/channel-postmessage": 7.0.0-beta.29 + "@storybook/channel-websocket": 7.0.0-beta.29 "@storybook/client-logger": 7.0.0-beta.29 "@storybook/core-common": 7.0.0-beta.29 "@storybook/csf-plugin": 7.0.0-beta.29 @@ -6082,7 +6084,7 @@ __metadata: rollup: ^3.0.0 slash: ^3.0.0 typescript: ~4.9.3 - vite: ^4.0.0 + vite: ^4.0.4 vite-plugin-externals: ^0.5.1 peerDependencies: "@preact/preset-vite": "*" @@ -7193,7 +7195,7 @@ __metadata: "@storybook/builder-vite": 7.0.0-beta.29 "@storybook/react": 7.0.0-beta.29 "@types/node": ^16.0.0 - "@vitejs/plugin-react": ^3.0.0 + "@vitejs/plugin-react": ^3.0.1 ast-types: ^0.14.2 magic-string: ^0.26.1 react-docgen: 6.0.0-alpha.3 @@ -9305,7 +9307,7 @@ __metadata: languageName: node linkType: hard -"@vitejs/plugin-react@npm:^3.0.0": +"@vitejs/plugin-react@npm:^3.0.1": version: 3.0.1 resolution: "@vitejs/plugin-react@npm:3.0.1" dependencies: @@ -29416,7 +29418,7 @@ __metadata: languageName: node linkType: hard -"vite@npm:^4.0.0": +"vite@npm:^4.0.0, vite@npm:^4.0.4": version: 4.0.4 resolution: "vite@npm:4.0.4" dependencies: