-
Notifications
You must be signed in to change notification settings - Fork 9
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
30182a3
commit d002439
Showing
4 changed files
with
44 additions
and
48 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
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 |
---|---|---|
@@ -1,40 +1,37 @@ | ||
const production = process.argv[2] === '--production'; | ||
import esbuild from 'esbuild'; | ||
|
||
const production = process.argv[2] === '--production'; | ||
const watch = process.argv[2] === '--watch'; | ||
const context = await esbuild | ||
.context({ | ||
entryPoints: ['./src/index.ts'], | ||
bundle: true, | ||
outdir: 'dist', | ||
external: ['vscode'], | ||
format: 'cjs', | ||
sourcemap: !production, | ||
minify: production, | ||
platform: 'node', | ||
target: 'ES2022', | ||
plugins: [ | ||
{ | ||
name: 'watch', | ||
setup(build) { | ||
build.onEnd(() => { | ||
if (watch) console.log('build finished'); | ||
}); | ||
build.onStart(() => { | ||
if (watch) console.log('building'); | ||
}); | ||
}, | ||
}, | ||
], | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); | ||
let desktopContext, browserContext; | ||
|
||
// This is the base config that will be used by both web and desktop versions of the extension | ||
const baseConfig = { | ||
entryPoints: ['./src/index.ts'], | ||
bundle: true, | ||
external: ['vscode'], | ||
sourcemap: !production, | ||
minify: production, | ||
target: 'ES2022', | ||
format: 'cjs', | ||
}; | ||
|
||
try { | ||
[desktopContext, browserContext] = await Promise.all([ | ||
// https://esbuild.github.io/getting-started/#bundling-for-node | ||
esbuild.context({ ...baseConfig, outfile: './dist/index.js', platform: 'node' }), | ||
// https://esbuild.github.io/getting-started/#bundling-for-the-browser | ||
esbuild.context({ ...baseConfig, outfile: './dist/browser.js', platform: 'browser' }), | ||
]); | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
|
||
if (watch) { | ||
await context.watch(); | ||
await desktopContext.watch(); | ||
await browserContext.watch(); | ||
} else { | ||
context.rebuild(); | ||
context.dispose(); | ||
desktopContext.rebuild(); | ||
browserContext.rebuild(); | ||
desktopContext.dispose(); | ||
browserContext.dispose(); | ||
} |
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