Dr.YSG
Dr.YSG

Reputation: 7591

getting babel to watch two folders

Goal: I have two sub-folders (jsx for jsx files) and (dash7 for ECMA-2017 scripts) I don't want to combine these folders. I want to setup a VSCODE tasks that can watch both folders.

Issue: Right now, I have two separate tasks. One "jsx watch" the other "es7 watch). I can only run one at a time with VS Code.

Question: is there a way to write a task that does both, or is there a way to get babel to watch two separate folders. Or another solution?

{
    "version": "0.1.0",
    "command": "${workspaceRoot}/node_modules/.bin/babel.cmd",
    // "isShellCommand": true,
    "tasks": [
        {
            "args": ["jsx", "--out-dir", "jsxo", "-w", "--source-maps inline"],
            "taskName": "jsx watch",
            "suppressTaskName": true,
            "isBuildCommand": true, // make this the F1 > Task: Run Build Task gesture
            "isBackground": true // tell VS Code not wait for this task to finish
        },
        {
            "args": ["dash7", "--out-dir", "dash", "-w", "--source-maps inline"],
            "taskName": "es7 watch",
            "suppressTaskName": true,
            "isBuildCommand": true, // make this the F1 > Task: Run Build Task gesture
            "isBackground": true // tell VS Code not wait for this task to finish
        }
    ]
}

babel presets

  "babel": {
    "sourceMaps": "inline",
    "presets": [
      "react",
      "node7"
    ]

Upvotes: 3

Views: 509

Answers (1)

Dr.YSG
Dr.YSG

Reputation: 7591

The VSCODE folks just updated Visual Code with a new terminal runner:

https://github.com/Microsoft/vscode/issues/981

If you change the version to 2.0.0 then you can run multiple tasks at once!

{
    "version": "2.0.0",
    "command": "${workspaceRoot}/node_modules/.bin/babel.cmd",
    // "isShellCommand": true,
    "tasks": [
        {
            "args": ["jsx", "--out-dir", "jsxo", "-w", "--source-maps inline"],
            "taskName": "jsx watch",
            "suppressTaskName": true,
            "isBuildCommand": true, // make this the F1 > Task: Run Build Task gesture
            "isBackground": true // tell VS Code not wait for this task to finish
        },
        {
            "args": ["dash7", "--out-dir", "dash", "-w", "--source-maps inline"],
            "taskName": "es7 watch",
            "suppressTaskName": true,
            "isBuildCommand": true, // make this the F1 > Task: Run Build Task gesture
            "isBackground": true // tell VS Code not wait for this task to finish
        }
    ]
}

Upvotes: 2

Related Questions