尝试 运行 gulp 任务 VSCode 不基于根文件夹
Trying to run a gulp task with VSCode which is not based in the root folder
这是我的task.json
// A task runner configuration for gulp. Gulp provides a less task
// which compiles less to css.
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "sfdcBuild",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Use the standard less compilation problem matcher.
"problemMatcher": "$lessCompile"
}
]
}
不幸的是,我的 gulp 安装(本地安装)不在根目录下,而是在另一个文件夹中:
root/js/
那么我如何定义我想从另一个文件夹中 运行 这个 gulp 命令?
PS:将 task.json 移动到子文件夹中也没有用。
tasks.json 目前不支持使用不同的 cwd
启动任务。一种解决方法是在工作区的根文件夹中创建一个 gulp.cmd
或 gulp.sh
文件来调用正确的 gulp
。例如。 gulp.cmd
:
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\gulp\bin\gulp.js" %*
为避免将此提交到您的 git 存储库,您可以在 .git/info/exclude
中忽略它
部分支持使用不同的工作目录。它不适用于 gulp 任务的自动检测,但它应该适用于 运行 gulp。您可以将类似的内容添加到顶级范围
中的 tasks.json
"options": {
"cwd": "${workspaceRoot}/mySubDir"
},
然而,这仍然假定 gulp 和 guld 需要的所有节点模块都可以从该目录访问。
您可以在 args
中将 gulpfile.js
的路径传递给 gulp
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--gulpfile",
"./js/gulpfile.js"
]
这是我的task.json
// A task runner configuration for gulp. Gulp provides a less task
// which compiles less to css.
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"tasks": [
{
"taskName": "sfdcBuild",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Use the standard less compilation problem matcher.
"problemMatcher": "$lessCompile"
}
]
}
不幸的是,我的 gulp 安装(本地安装)不在根目录下,而是在另一个文件夹中:
root/js/
那么我如何定义我想从另一个文件夹中 运行 这个 gulp 命令?
PS:将 task.json 移动到子文件夹中也没有用。
tasks.json 目前不支持使用不同的 cwd
启动任务。一种解决方法是在工作区的根文件夹中创建一个 gulp.cmd
或 gulp.sh
文件来调用正确的 gulp
。例如。 gulp.cmd
:
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\gulp\bin\gulp.js" %*
为避免将此提交到您的 git 存储库,您可以在 .git/info/exclude
部分支持使用不同的工作目录。它不适用于 gulp 任务的自动检测,但它应该适用于 运行 gulp。您可以将类似的内容添加到顶级范围
中的 tasks.json"options": {
"cwd": "${workspaceRoot}/mySubDir"
},
然而,这仍然假定 gulp 和 guld 需要的所有节点模块都可以从该目录访问。
您可以在 args
gulpfile.js
的路径传递给 gulp
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--gulpfile",
"./js/gulpfile.js"
]