mtcute-repl/packages/worker/scripts/build-iframe-script.ts

27 lines
601 B
TypeScript
Raw Normal View History

2025-01-19 19:54:44 +03:00
import { fileURLToPath } from 'node:url'
import { config } from 'dotenv'
import { build } from 'esbuild'
config({
path: fileURLToPath(new URL('../../../.env', import.meta.url)),
})
2025-01-19 21:39:53 +03:00
const defines: Record<string, string> = {}
for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith('VITE_')) {
defines[`import.meta.env.${key}`] = JSON.stringify(value)
}
}
2025-01-19 19:54:44 +03:00
await build({
entryPoints: ['src/sw/iframe/script.ts'],
bundle: true,
format: 'esm',
outfile: 'src/sw/iframe/script-bundled.js',
2025-01-19 21:39:53 +03:00
define: defines,
external: [
'@mtcute/web',
],
2025-01-19 21:39:53 +03:00
minify: true,
2025-01-19 19:54:44 +03:00
})