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(plugin-storybook): remove dist dir when build #2908

Merged
merged 1 commit into from
Feb 16, 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
fix(plugin-storybook): remove dist dir when build
  • Loading branch information
targeral committed Feb 16, 2023
commit 61137a6e6781c28f8ac6bfb4a428437c1e12b2b9
6 changes: 6 additions & 0 deletions .changeset/tender-emus-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/plugin-storybook': patch
---

fix(plugin-storybook): remove dist dir when modern build
fix(plugin-storybook): 当执行 modern build 后,移除产物目录
14 changes: 14 additions & 0 deletions packages/cli/plugin-storybook/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from 'path';
import { createRuntimeExportsUtils } from '@modern-js/utils';
import type { CliPlugin, ModuleTools } from '@modern-js/module-tools';
import { defaultStories, appToolsStories } from './constants/stores';
Expand Down Expand Up @@ -39,6 +40,19 @@ export default (pluginOption: PluginOptions = {}): CliPlugin<ModuleTools> => ({
return config;
},

beforeBuild: async () => {
const { fs } = await import('@modern-js/utils');
const { STORYBOOK_DIST_DIR_NAME } = await import('./features/constants');
const { appDirectory } = api.useAppContext();
const storybookDistPath = path.join(
appDirectory,
'dist',
chenjiahan marked this conversation as resolved.
Show resolved Hide resolved
STORYBOOK_DIST_DIR_NAME,
);
// If the path does not exist, `fs.remove` silently does nothing.
await fs.remove(storybookDistPath);
},

registerDev() {
return {
name: 'storybook',
Expand Down