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: storybook build #367

Merged
merged 2 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { type Preview } from '@storybook/react';
import { Buffer } from 'buffer'

globalThis.Buffer = Buffer

// import CSS files
import 'ipfs-css'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"start": "cross-env NODE_ENV=production babel src -d dist --copy-files --no-copy-ignored --extensions '.ts,.tsx,.js,.jsx' --watch",
"test": "vitest run --environment=node",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"storybook:build": "storybook build"
},
"dependencies": {
"@chainsafe/libp2p-gossipsub": "^8.0.0",
Expand Down
8 changes: 5 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function reactVirtualized (): PluginOption {
}

// https://vitejs.dev/config/
export default defineConfig(() => {
export default defineConfig(({ mode, command }) => {
const vitePlugins: UserConfig['plugins'] = [
react(),
svgrPlugin(),
Expand All @@ -49,9 +49,11 @@ export default defineConfig(() => {
alias: [{ find: '@', replacement: pathResolve(__dirname, '/src') }]
}

const viteDefine: UserConfig['define'] = {
global: 'globalThis'
const viteDefine: UserConfig['define'] = {}
if (mode === 'development' && command === 'serve') {
viteDefine.global = 'globalThis'
}

const viteOptimizeDeps: UserConfig['optimizeDeps'] = {
esbuildOptions: {
loader: {
Expand Down