Skip to content

Commit

Permalink
updates to release and esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Mar 28, 2024
1 parent 68910a7 commit eb202e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ jobs:
gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css
build/main.js manifest.json styles.css
19 changes: 7 additions & 12 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ import console from 'console';

const prod = process.argv[2] === 'production';

// if (!prod) {
// try {
// fs.copyFile('manifest.json', 'build/manifest.json', (err) => {
// if (err) console.log(err);
// });
// fs.copyFile('styles.css', 'build/styles.css', (err) => {
// if (err) console.log(err);
// });
// } catch (error) {}
// }

const context = await esbuild.context({
entryPoints: ['src/main.ts'],
bundle: true,
Expand All @@ -41,13 +30,19 @@ const context = await esbuild.context({
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js'
outfile: 'build/main.js'
});

if (prod) {
console.log('Building for production');
await context.rebuild();
process.exit(0);
} else {
fs.copyFile('manifest.json', 'build/manifest.json', (err) => {
if (err) console.log(err);
});
fs.copyFile('styles.css', 'build/styles.css', (err) => {
if (err) console.log(err);
});
await context.watch();
}

0 comments on commit eb202e7

Please sign in to comment.