/** * This script builds a production output of all of our bundles. */ import { resolve as pathResolve } from 'path'; import * as fs from 'fs-extra'; import { logger } from '@spine/logger'; import { getBuildPath } from '@erect/core/paths'; import { config } from '@erect/core/config'; import { cliCleanHook } from '../hooks'; const log = logger('erect:clean'); export async function clean(target: string) { const { buildOutputDir } = target === 'client' || target === 'server' ? config.bundles[target] : config.additionalNodeBundles[target]; fs.removeSync(pathResolve(getBuildPath(), buildOutputDir)); log.info(`Cleaned build "${target}"`); } cliCleanHook.addAction('default', async ({ target }) => { const targets = target == null ? [ 'client', 'server', ...Object.keys(config.additionalNodeBundles), ] : target; for (const target of targets) { await clean(target); } });