Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HMR issue in Manager UI #20654

Merged
merged 2 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/frameworks/react-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion code/lib/builder-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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": "*",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/builder-vite/src/vite-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 20 additions & 13 deletions code/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
8 changes: 4 additions & 4 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6082,7 +6082,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": "*"
Expand Down Expand Up @@ -7193,7 +7193,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
Expand Down Expand Up @@ -9305,7 +9305,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:
Expand Down Expand Up @@ -29416,7 +29416,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:
Expand Down