Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for brushless servo upgrade #197

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { context, build } from 'esbuild';
import inlineWorker from 'esbuild-plugin-inline-worker';
import { htmlPlugin as html } from '@craftamap/esbuild-plugin-html';

const buildOptions = {
entryPoints: ['src/ui.tsx'],
bundle: true,
platform: 'browser',
target: 'es2020',
minify: true,
sourcemap: true,
metafile: true,
logLevel: 'debug',
outdir: 'dist/ui',
tsconfig: 'tsconfig.web.json',
loader: { '.svg': 'file' },
define: {
IS_WEB: process.env.IS_WEB ?? '0',
},
plugins: [ inlineWorker(),
html({
files: [{
entryPoints: [ 'src/ui.tsx'],
filename: 'index.html',
htmlTemplate: 'src/index.html',
scriptLoading: 'defer',
}]
})
],
resolveExtensions: ['.js', '.ts', '.tsx', '.svg', '.worker.js'],
};

(async () => {
try {
if (process.env.BUILD_MODE === 'development') {
// enables live-reloading
const ctx = await context({
...buildOptions,
banner: { js: "new EventSource('/esbuild').addEventListener('change', () => location.reload());" }
})
await ctx.watch();
const { host, port } = await ctx.serve({servedir: 'dist/ui', port: 9080 });
console.log(`http://${host}:${port}`)
} else {
await build(buildOptions);
}
} catch (error) {
console.error(error);
process.exit(1);
}
})();

Loading
Loading