Skip to content

Commit

Permalink
feat: support JS build process (#141)
Browse files Browse the repository at this point in the history
* 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
dustin-jw authored Feb 26, 2024
1 parent 6017bd2 commit db61ff5
Show file tree
Hide file tree
Showing 22 changed files with 557 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = {
env: {
browser: true,
commonjs: true,
node: true,
es2021: true,
},
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
},
ignorePatterns: ['dist', 'node_modules'],
Expand Down
28 changes: 28 additions & 0 deletions esbuild.mjs
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);
}
Loading

0 comments on commit db61ff5

Please sign in to comment.