generated from dustin-jw/eleventy-starter-lite
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support JS build process (#141)
* chore: install esbuild * chore: incorporate esbuild into build process * refactor: reference built JS files * refactor: move/rename game selection functions * refactor: move pagination functions to helpers * fix: update page title to match randomized order * refactor: pull most logic into helper functions/files * style: add clarifying comments * style: remove empty line before JSON output
- Loading branch information
Showing
22 changed files
with
557 additions
and
100 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as esbuild from 'esbuild'; | ||
import { config } from 'dotenv'; | ||
|
||
config(); | ||
|
||
const isProduction = process.env.NODE_ENV !== 'development'; | ||
|
||
const options = { | ||
entryPoints: ['src/js/*.js'], | ||
format: 'esm', | ||
bundle: true, | ||
splitting: true, | ||
outdir: 'dist/js', | ||
// run `npx browserslist` to find updated minimum versions to set here | ||
target: ['chrome109', 'edge109', 'firefox109', 'safari15.5', 'opera94'], | ||
sourcemap: isProduction ? false : 'inline', | ||
minify: isProduction, | ||
logLevel: 'info', | ||
}; | ||
|
||
if (!isProduction) { | ||
// watch for changes and rebuild during development | ||
let context = await esbuild.context(options); | ||
await context.watch(); | ||
} else { | ||
// build once and exit | ||
await esbuild.build(options); | ||
} |
Oops, something went wrong.