Gulp运行的任务多于指定的任务

时间:2017-04-20 04:12:11

标签: gulp

我已经设置了一个gulpfile,其中包含一系列任务,可以使用systemjs和webpack捆绑Angular2应用程序。不幸的是,我看到如果我在我的Powershell提示符中运行其中一个(例如“gulp webpack”或“gulp systemjs”而没有引号),它实际上会执行比我期望的任务中指定的任务更多的任务。 / p>

为简洁起见,我不会列出我在此范围内完成的所有任务,但它们都遵循标准方法,如下例所示:

gulp.task("angular",
    () => {
        var angularDirs = "./Scripts/MyApp/src/**/*.{html,css}";

        return gulp.src(angularDirs)
            .pipe(copy(config.wwwroot, { prefix: 1 }))
            .pipe(gulp.dest(config.wwwroot));
    });

例如,这是我为webpack任务所做的事情:

gulp.task("webpack", runSequence(["cleanRoot", "cleanBuild"],
    ["ts:webpack", "restore", "less", "angular", "webpackHtml", "javascript:webpack"]));

...这就是我在systemjs任务中得到的:

gulp.task("systemjs", runSequence(["cleanRoot", "cleanBuild"], "embedTemplates",
    "ts:systemjs", ["less", "restore", "angular"], "cleanWrongIndex"));

所以,那里有一些重叠,但这是有意的。但是,如果我运行“gulp systemjs”,我希望它只会实际运行“cleanRoot”和“cleanBuild”,然后“embedTemplates”,然后“ts:systemjs”,“less”,“restore”和“angular”任务,最后是“cleanWrongIndex”,并且文件中没有任何其他任务。然而...

PS C:\Code\MyApp> gulp systemjs
[22:56:59] Using gulpfile
[22:56:59] Starting 'systemjs'...
[22:56:59] Finished 'systemjs' after 128 μs
[22:57:00] Finished 'cleanBuild' after 1.12 s
[22:57:01] Starting 'embedTemplates'...
**[22:57:01] Starting 'ts:webpack'...**
[22:57:01] Starting 'restore'...
[22:57:01] Starting 'less'...
[22:57:01] Starting 'angular'...
**[22:57:01] Starting 'webpackHtml'...**
**[22:57:01] Finished 'webpackHtml' after 705 μs**
**[22:57:01] Starting 'javascript:webpack'...**
**[22:57:01] Finished 'javascript:webpack' after 1.5 ms**
[22:57:01] Finished 'cleanRoot' after 1.9 s
[22:57:01] Finished 'restore' after 68 ms
[22:57:06] Finished 'less' after 5.65 s
[22:57:07] Finished 'angular' after 6.26 s
**[22:57:13] Finished 'ts:webpack' after 12 s**
**[22:57:14] Starting 'ts:systemjs'...**
[22:57:14] Finished 'embedTemplates' after 13 s
[22:57:20] Starting 'less'....
[22:57:20] Starting 'restore'...
[22:57:20] Starting 'angular'...
**[22:57:20] Finished 'ts:systemjs' after 5.64 s**
[22:57:20] Finished 'restore' after 161 ms
[22:57:23] Finished 'less' after 3.32 s
[22:57:23] Finished 'angular' after 3.79 s
[22:57:38] Starting 'restore'...
[22:57:38] Starting 'cleanWrongIndex'...
[22:57:38] Finished 'restore' after 25 μs
[22:57:38] Finished 'cleanWrongIndex' after 4.97 ms
PS C:\Code\MyApp>

我区分了上面那些不应该存在的任务,因为它们在webpack任务中并且没有在这个任务中指定。

为什么我没有指明任务?有没有办法强制gulp只运行我指定的任务?

谢谢!

0 个答案:

没有答案