-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7390291
commit d8c72e7
Showing
8 changed files
with
6,096 additions
and
966 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,50 @@ | ||
// Import esbuild | ||
import ESBuild from 'esbuild' | ||
|
||
// Is server requested? | ||
const serve = process.argv.some((arg) => (arg.toLowerCase() === 'serve')) | ||
|
||
// Is this a dev build? | ||
const _DEV_ = process.argv.some((arg) => (arg.toLowerCase() === 'dev')) | ||
|
||
// esbuild options | ||
const options = { | ||
// List of all separate entry points | ||
entryPoints: [ | ||
'./src/main.jsx' | ||
], | ||
|
||
// Configure output location and names | ||
outdir: './public', | ||
entryNames: '/[name]', | ||
|
||
// Configure output types | ||
bundle: true, | ||
sourcemap: _DEV_, | ||
minify: (!_DEV_), | ||
|
||
// Define important variables | ||
define: { | ||
_VER_: `"${process.env.npm_package_version}"`, | ||
_DEV_, | ||
'process.env.NODE_ENV': (_DEV_ ? '"development"' : '"production"') | ||
} | ||
} | ||
|
||
// Start up server if requested | ||
if (serve) { | ||
ESBuild.serve({ port: 3000, servedir: 'public' }, options) | ||
.then(server => { | ||
console.log(`Serving dev code at ${server.host}:${server.port}`) | ||
}) | ||
.catch(() => { | ||
process.exit(1) | ||
}) | ||
} else { | ||
// Attempt to build | ||
ESBuild.build(options).catch( | ||
() => { | ||
process.exit(1) | ||
} | ||
) | ||
} |
Oops, something went wrong.