🌳
pt0/deployF/devpconlyF/doBuildSwF.mts
1import esbuild from 'esbuild'
7export const doBuildSw = async ({doWatch}: {doWatch?: boolean}={}) => {
8 const {appPath} = getAppCfg()
10 const ptOutPath = pathDownJoin(appPath!, 'public', getReqPubEnvItem('builtSwFilename') as string)
11 const ptInPath = pathDownJoin(appPath!, 'entrypoints', 'sw.mjs')
13 const absOutPath = pathDownJoin(ptDir, ptOutPath)
14 const buildOptions = {
15 entryPoints: [
16 pathDownJoin(ptDir, ptInPath)
17 ],
18 bundle: true,
19 outfile: absOutPath,
20 // outdir: outPath,
21 format: 'iife' as const,
22 jsx: 'automatic' as const,
23 minify: true,
24 }
26 await esbuild.build(buildOptions)
27 console.log('builtsw', ptInPath, '->', ptOutPath)
29 if (doWatch) {
30 const ctx = await esbuild.context(buildOptions)
31 await ctx.watch()
32 console.log('Watching for changes...')
33 }