| 2 | const path = require('path'); |
| 3 | |
| 4 | const createBuildConfig = (format) => ({ |
| 5 | entryPoints: ['src/index.ts'], |
| 6 | bundle: true, |
| 7 | format, |
| 8 | outfile: format === 'esm' ? 'dist/index.esm.js' : 'dist/index.js', |
| 9 | external: ['react', 'react-dom'], |
| 10 | target: ['es2020'], |
| 11 | jsx: 'automatic', |
| 12 | jsxImportSource: 'react', |
| 13 | minify: process.env.NODE_ENV === 'production', |
| 14 | sourcemap: true, |
| 15 | platform: 'browser', |
| 16 | splitting: false, |
| 17 | loader: { |
| 18 | '.tsx': 'tsx', |
| 19 | '.ts': 'ts', |
| 20 | '.js': 'js', |
| 21 | '.jsx': 'jsx' |
| 22 | }, |
| 23 | define: { |
| 24 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') |
| 25 | } |
| 26 | }); |
| 27 | |
| 28 | const buildAll = async () => { |
| 29 | try { |