Skip to content

Commit

Permalink
Merge pull request #87 from tauling/esbuild_0.18
Browse files Browse the repository at this point in the history
Adding support for esbuild 0.18 and live reloading
  • Loading branch information
nelsonic authored Jan 2, 2024
2 parents b97ad49 + d4d645e commit 9b19691
Show file tree
Hide file tree
Showing 10 changed files with 3,804 additions and 319 deletions.
45 changes: 33 additions & 12 deletions assets/elm/build.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
const esbuild = require('esbuild');
const ElmPlugin = require('esbuild-plugin-elm');

esbuild.build({
entryPoints: ['src/index.js'],
bundle: true,
outdir: '../js',
watch: process.argv.includes('--watch'),
plugins: [
ElmPlugin({
debug: true,
clearOnWatch: true,
}),
],
}).catch(_e => process.exit(1))
const isProduction = process.env.MIX_ENV === "prod"

async function watch() {
const ctx = await esbuild.context({
entryPoints: ['src/index.js'],
bundle: true,
outfile: '../js/elm.js',
plugins: [
ElmPlugin({
debug: true
}),
],
}).catch(_e => process.exit(1))
await ctx.watch()
}


async function build() {
await esbuild.build({
entryPoints: ['src/index.js'],
bundle: true,
minify: true,
outfile: '../js/elm.js',
plugins: [
ElmPlugin(),
],
}).catch(_e => process.exit(1))
}

if (isProduction)
build()
else
watch()
Loading

0 comments on commit 9b19691

Please sign in to comment.