diff --git a/examples/ant-pro/.gitignore b/examples/ant-pro/.gitignore index 0fb3670..1dae949 100644 --- a/examples/ant-pro/.gitignore +++ b/examples/ant-pro/.gitignore @@ -39,3 +39,4 @@ screenshot .eslintcache build +.takumi/todos diff --git a/packages/bundler-shared-config/src/provider/BaseBundler.ts b/packages/bundler-shared-config/src/provider/BaseBundler.ts index e733956..051769b 100644 --- a/packages/bundler-shared-config/src/provider/BaseBundler.ts +++ b/packages/bundler-shared-config/src/provider/BaseBundler.ts @@ -5,7 +5,7 @@ import type { Stats, } from '@kmijs/bundler-shared/rspack' import type { Configuration } from '@kmijs/bundler-shared/rspack' -import { logger } from '@kmijs/shared' +import { logger, rimraf } from '@kmijs/shared' import { Env, type IUserConfig } from '../types' import { esbuildCompressErrorHelper } from '../utils/esbuildCompressErrorHelper' import type { @@ -72,6 +72,23 @@ export abstract class BaseBundler< let isFirstCompile = true return new Promise((resolve, reject) => { + if (opts.clean) { + bundlerConfigs.forEach((config) => { + if (config.output?.path) { + try { + logger.verbose( + `[BaseBundler] Cleaning output directory: ${config.output.path}`, + ) + rimraf.sync(config.output.path) + } catch (error) { + logger.verbose( + `[BaseBundler] Cleaning output directory: ${config.output.path} failed`, + ) + } + } + }) + } + const compiler = this.createCompiler({ ...buildOptions, bundlerConfigs,