mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-23 05:02:10 +08:00
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import fs from 'fs-extra';
|
|
import { join } from 'path';
|
|
import { build } from 'tsup';
|
|
|
|
const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
|
|
const packageJson = await fs.readJson(join(cwd, 'package.json'));
|
|
|
|
await build({
|
|
entry: packageJson.bundlerEntrypoint,
|
|
watch: flags.includes('--watch'),
|
|
// sourcemap: flags.includes('--optimized'),
|
|
format: ['esm', 'cjs'],
|
|
target: 'node16',
|
|
clean: true,
|
|
shims: true,
|
|
|
|
dts: {
|
|
entry: packageJson.bundlerEntrypoint,
|
|
resolve: true,
|
|
},
|
|
esbuildOptions: (c) => {
|
|
/* eslint-disable no-param-reassign */
|
|
c.platform = 'node';
|
|
c.legalComments = 'none';
|
|
c.minifyWhitespace = !!flags.includes('--optimized');
|
|
c.minifyIdentifiers = !!flags.includes('--optimized');
|
|
c.minifySyntax = !!flags.includes('--optimized');
|
|
/* eslint-enable no-param-reassign */
|
|
},
|
|
});
|
|
};
|
|
|
|
const flags = process.argv.slice(2);
|
|
const cwd = process.cwd();
|
|
|
|
run({ cwd, flags }).catch((err) => {
|
|
console.error(err.stack);
|
|
process.exit(1);
|
|
});
|