Compiling with a Build Task in VS Code

The emcc command is a little verbose, and having to manually run this on the command line for different files can get cumbersome. To expedite the compilation process, we can use VS Code's Tasks feature to create a build task for the files we'll use. To create a build task, select Tasks | Configure Default Build Task…, select the Create tasks.json from template option, and select Others to generate a simple tasks.json file in the .vscode folder. Update the contents of the file to contain the following:

{  // See https://go.microsoft.com/fwlink/?LinkId=733558  // for the documentation about the tasks.json format  "version": "2.0.0",  "tasks": [    {      "label": "Build",      "type": "shell",      "command": "emcc", "args": ...

Get Learn WebAssembly now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.