When you’re making changes in VSCode and you want a quick check to make sure the project compiles, you can either reach for a terminal and type
mix compile or set up a quick build in VSCode and trigger it via a keyboard shortcut. I’ll show you how to set up the latter.
- Look for a .vscode folder in your project (or create one)
- Look for a tasks.json file in your .vscode directory or create that file
- Insert the following task configuration in that file:
"label": "mix: compile",
"command": "mix compile",
- Note: If you already have a task in there, then just append the object in the
tasksarray above to your existing tasks array.
- Save the file. You shouldn’t need to restart VSCode for it to take effect, but try that if the next steps don’t work.
- Trigger the command using Terminal -> Run Build Task, or the keyboard shortcut attached to that (mine is Shift + CMD + B, on Mac).
- You should then see a terminal window pop up in your editor with text similar to the following (with “tictactoe” being whatever your app is named, of course):
Now, anytime you need a quick sanity check that your code still compiles and doesn’t have any big errors, trigger that build task using your keyboard shortcut. It should speed up your development cycle a touch.