[improvement] repo, scripts (#220)
* Fix menu, cleanup package.json * update changelog
This commit is contained in:
parent
fb77323ef2
commit
ec3dae085c
16 changed files with 344 additions and 171 deletions
46
example/scripts/build.mjs
Normal file
46
example/scripts/build.mjs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* eslint-disable */
|
||||
import fs from 'fs'
|
||||
import esbuild from 'esbuild'
|
||||
import { createRequire } from 'module'
|
||||
|
||||
const pkg = createRequire(import.meta.url)('../package.json')
|
||||
|
||||
async function main() {
|
||||
if (fs.existsSync('./dist')) {
|
||||
fs.rmSync('./dist', { recursive: true }, (e) => {
|
||||
if (e) {
|
||||
throw e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
esbuild.buildSync({
|
||||
entryPoints: ['./src/index.tsx'],
|
||||
outdir: 'dist',
|
||||
minify: true,
|
||||
bundle: true,
|
||||
format: 'cjs',
|
||||
target: 'es6',
|
||||
jsxFactory: 'React.createElement',
|
||||
jsxFragment: 'React.Fragment',
|
||||
tsconfig: './tsconfig.json',
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
},
|
||||
metafile: false,
|
||||
sourcemap: false,
|
||||
})
|
||||
|
||||
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
|
||||
console.log(`✔ ${pkg.name}: Build completed.`)
|
||||
} catch (e) {
|
||||
console.log(`× ${pkg.name}: Build failed due to an error.`)
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue