Skip to content

Commit

Permalink
chore: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Nov 14, 2022
2 parents 625497d + b77c816 commit 6a97663
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,29 @@ export async function build(options: BuildOptions) {
const { filePath, publicDir, esbuildOptions, outputDir } = options

const fileName = path.basename(filePath, path.extname(filePath))
try {
const res = await esbuild({
entryPoints: [filePath],
write: false,
platform: 'browser',
bundle: true,
format: 'iife',
sourcemap: false,
treeShaking: true,
splitting: false,
minify: true,
...esbuildOptions,
})

const code = res.outputFiles?.[0].text

await deleteOldFiles({
...options,
publicDir,
fileName,
outputDir,
})

await addJsFile({ ...options, code, fileName })
} catch {}
const res = await esbuild({
entryPoints: [filePath],
write: false,
platform: 'browser',
bundle: true,
format: 'iife',
sourcemap: false,
treeShaking: true,
splitting: false,
minify: true,
...esbuildOptions,
})

const code = res.outputFiles?.[0].text

await deleteOldFiles({
...options,
publicDir,
fileName,
outputDir,
})

await addJsFile({ ...options, code, fileName })
}

type TDeleteFile = {
Expand Down

0 comments on commit 6a97663

Please sign in to comment.