Sha256: 19592b78e782bb988d508e923968ff87f87ec4f28f91db26194ce049644c911a
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
import { build, stop } from 'esbuild' import envPlugin from '../esbuild/env_plugin.js' import resolvePlugin from '../esbuild/resolve_plugin.js' export default async (cwd, entrypoint) => { const railsEnv = Deno.env.get('RAILS_ENV') const isProd = railsEnv === 'production' let entrypointIsSourcemap = false if (/\.js\.map$/.test(entrypoint)) { entrypoint = entrypoint.replace(/\.map$/, '') entrypointIsSourcemap = true } const params = { entryPoints: [entrypoint], absWorkingDir: cwd, logLevel: 'error', sourcemap: !entrypointIsSourcemap ? false : 'linked', outdir: 'public', outbase: './', write: false, format: 'esm', minify: isProd, bundle: true, plugins: [envPlugin(), resolvePlugin({ debug: false })] } try { const result = await build(params) if (params.sourcemap === 'linked') { if (entrypointIsSourcemap) { return result.outputFiles[0].contents } else { return result.outputFiles[1].contents } } else { return result.outputFiles[0].contents } } finally { stop() } }
Version data entries
6 entries across 6 versions & 1 rubygems