2021-08-10 16:12:55 +00:00
|
|
|
|
/* eslint-disable */
|
|
|
|
|
const fs = require('fs')
|
|
|
|
|
const esbuild = require('esbuild')
|
|
|
|
|
|
|
|
|
|
const name = process.env.npm_package_name || ''
|
|
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
|
try {
|
|
|
|
|
esbuild.buildSync({
|
|
|
|
|
entryPoints: ['./src/index.ts'],
|
|
|
|
|
outdir: 'dist/cjs',
|
|
|
|
|
minify: false,
|
|
|
|
|
bundle: true,
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
target: 'es6',
|
|
|
|
|
jsxFactory: 'React.createElement',
|
|
|
|
|
jsxFragment: 'React.Fragment',
|
2021-08-14 15:46:21 +00:00
|
|
|
|
tsconfig: './tsconfig.build.json',
|
2021-08-10 16:12:55 +00:00
|
|
|
|
external: ['react', 'react-dom'],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
fs.copyFile('./README.md', './dist/README.md', (err) => {
|
|
|
|
|
if (err) throw err
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log(`✔ ${name}: Built package.`)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(`× ${name}: Build failed due to an error.`)
|
|
|
|
|
console.log(e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main()
|