build(component): fix component storybook (#9990)

This commit is contained in:
forehalo
2025-02-06 15:58:10 +00:00
parent 1652e6df6b
commit 2ff31c6274
5 changed files with 9 additions and 5 deletions

View File

@@ -3,7 +3,6 @@ import { StorybookConfig } from '@storybook/react-vite';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import swc from 'unplugin-swc'; import swc from 'unplugin-swc';
import { mergeConfig } from 'vite'; import { mergeConfig } from 'vite';
import { getBuildConfig } from '@affine-tools/utils/build-config';
export default { export default {
stories: ['../src/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'], stories: ['../src/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
@@ -26,6 +25,9 @@ export default {
docs: {}, docs: {},
async viteFinal(config, _options) { async viteFinal(config, _options) {
const { getBuildConfig } = await import('@affine-tools/utils/build-config');
const { Package } = await import('@affine-tools/utils/workspace');
return mergeConfig(config, { return mergeConfig(config, {
plugins: [ plugins: [
vanillaExtractPlugin(), vanillaExtractPlugin(),
@@ -55,12 +57,9 @@ export default {
define: { define: {
'process.env.CAPTCHA_SITE_KEY': `"${process.env.CAPTCHA_SITE_KEY}"`, 'process.env.CAPTCHA_SITE_KEY': `"${process.env.CAPTCHA_SITE_KEY}"`,
...Object.entries( ...Object.entries(
getBuildConfig({ getBuildConfig(new Package('@affine/web'), {
distribution: 'web',
mode: 'development', mode: 'development',
channel: 'canary', channel: 'canary',
static: false,
coverage: false,
}) })
).reduce((envs, [key, value]) => { ).reduce((envs, [key, value]) => {
envs[`BUILD_CONFIG.${key}`] = JSON.stringify(value); envs[`BUILD_CONFIG.${key}`] = JSON.stringify(value);

View File

@@ -1,6 +1,7 @@
{ {
"name": "@affine/component", "name": "@affine/component",
"private": true, "private": true,
"type": "module",
"main": "./src/index.ts", "main": "./src/index.ts",
"exports": { "exports": {
".": "./src/index.ts", ".": "./src/index.ts",
@@ -64,6 +65,7 @@
"zod": "^3.24.1" "zod": "^3.24.1"
}, },
"devDependencies": { "devDependencies": {
"@affine-tools/utils": "workspace:*",
"@blocksuite/affine": "workspace:*", "@blocksuite/affine": "workspace:*",
"@blocksuite/icons": "2.2.2", "@blocksuite/icons": "2.2.2",
"@chromatic-com/storybook": "^3.2.2", "@chromatic-com/storybook": "^3.2.2",

View File

@@ -16,6 +16,7 @@
{ "path": "../electron-api" }, { "path": "../electron-api" },
{ "path": "../graphql" }, { "path": "../graphql" },
{ "path": "../i18n" }, { "path": "../i18n" },
{ "path": "../../../tools/utils" },
{ "path": "../../../blocksuite/affine/all" } { "path": "../../../blocksuite/affine/all" }
] ]
} }

View File

@@ -609,6 +609,7 @@ export const PackageList = [
'packages/frontend/electron-api', 'packages/frontend/electron-api',
'packages/frontend/graphql', 'packages/frontend/graphql',
'packages/frontend/i18n', 'packages/frontend/i18n',
'tools/utils',
'blocksuite/affine/all', 'blocksuite/affine/all',
], ],
}, },

View File

@@ -270,6 +270,7 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@affine/component@workspace:packages/frontend/component" resolution: "@affine/component@workspace:packages/frontend/component"
dependencies: dependencies:
"@affine-tools/utils": "workspace:*"
"@affine/debug": "workspace:*" "@affine/debug": "workspace:*"
"@affine/electron-api": "workspace:*" "@affine/electron-api": "workspace:*"
"@affine/graphql": "workspace:*" "@affine/graphql": "workspace:*"