-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from tauling/esbuild_0.18
Adding support for esbuild 0.18 and live reloading
- Loading branch information
Showing
10 changed files
with
3,804 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.