3

I am new to VSCode. I am new to ELM.

I am perfectly capable of using VIM and command line tools to create an ELM Project, but I want to utilize an IDE. I have chosen VSCode on advice from the internet since it seems to pick up some nice pieces of VIM.

So now I have a few .elm files.

Main.elm
View.elm
Model.elm

I want to run elm-make on Model.elm to make sure it has no errors.

Then I want to run elm-make on Main.elm to create an index.html so I can view my project.

I think this is a pretty simple question for people familiar with how to customize VSCode, but as I stated previously, I am new to VSCode.

Owen Ivory
  • 244
  • 1
  • 9

1 Answers1

1

Try setting up a task for elm-make:

Create a ./vscode/tasks.json with the contents:

{
    "version": "0.1.0",
    "tasks": [
        {
            "taskName": "elm make",
            "isBuildCommand": true,
            "command": "elm-make",
            "args": ["./main.elm"],
            "isShellCommand": true
        }
    ]
}

You can then use the build command to run the task, or run the task individually.

You may also want to look into the elm extension: https://marketplace.visualstudio.com/items?itemName=sbrink.elm

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
  • 1
    While I am pretty sure your answer is correct, it is possible I did not stress the "I am new to VSCode" statement enough. Items which are unclear include where should the .vscode/ directory exist? Once the task has been created, how would I execute the task? – Owen Ivory Jun 14 '17 at 22:20
  • The `.vscode` directory should be in the root of your workspace. You can run tasks in a few different ways. Two easy ones: use the `Run Task` command in the command palette or the `Run Build task` command which is bound to `cmd+shift+b` by default. You can find more info about VSCode task in the [tasks documentation](https://code.visualstudio.com/Docs/editor/tasks) – Matt Bierner Jun 14 '17 at 22:33
  • While your answer is a great start, The real key is the documentation which allowed me to link a task to a windows command. The task as you have provided above does not run elm-make in the current directory, and always compiles the file main.elm. ${file} and {$DirFilename} from the documentation solve that problem. Tasks are a pita to run, but the documentation identifies keybinding solutions and how to make them too. Thanks for getting me started. – Owen Ivory Jun 15 '17 at 17:13