How to run multiple tasks in VS Code on build?

后端 未结 4 1678
感动是毒
感动是毒 2021-01-31 09:36

Using tasks.json version 2.0.0, I have not been able to make it so that, when I build my application, multiple tasks are run at the same time. I\'m using gulp for m

相关标签:
4条回答
  • 2021-01-31 09:57

    Add 'gulp-load-plugins' plugin in package.json

    var gulpLoadPlugins = require('gulp-load-plugins'),
    plugins = gulpLoadPlugins();
    

    To read more about that plugin, see How To Build And Develop Websites With Gulp

    0 讨论(0)
  • 2021-01-31 10:09

    You can use Compound Tasks.

    The example below executes "Client Build" and "Server Build" tasks when "Build" task is called.

    {
      "version": "2.0.0",
      "tasks": [
        {
          "label": "Client Build",
          "command": "gulp",
          "args": ["build"],
          "options": {
            "cwd": "${workspaceFolder}/client"
          }
        },
        {
          "label": "Server Build",
          "command": "gulp",
          "args": ["build"],
          "options": {
            "cwd": "${workspaceFolder}/server"
          }
        },
        {
          "label": "Build",
          "dependsOn": ["Client Build", "Server Build"]
        }
      ]
    }
    
    0 讨论(0)
  • 2021-01-31 10:13

    The problem is that "Run Test Task" and "Run Build Task" do not execute all tasks in that specific group. Usually you get a drop down selection so you can choose which task to execute. Since you have specified one of the tasks as default, the selection will be skipped and instead the default task is executed.

    You can work around that by adding dependencies. Take the following example:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Echo 1",
                "command": "echo",
                "type": "shell",
                "args": [ "echo1" ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "dependsOn":["Echo 2"]
            },
            {
                "label": "Echo 2",
                "type": "shell",
                "command": "echo",
                "args": [ "echo2" ],
                "group": "build"
            }
        ]
    }
    

    As Echo 1 depends on Echo 2, Echo 2 will be executed prior to executing Echo 1. Note that the definition is a list, so more than one task can be specified. In that case the tasks are executed in parallel.

    In your case adding "dependsOn":["Compile/minify cms.scss"] to your main build task should execute both tasks.

    0 讨论(0)
  • 2021-01-31 10:16

    Double check your settings are enabled for Gulp auto-detection:

    "gulp.autoDetect": "on"
    
    0 讨论(0)
提交回复
热议问题