簡體   English   中英

gulp-nodemon觀看打字稿文件

[英]gulp-nodemon watch typescript files

我有2個目錄:

  • es5 javascript files compiled by gulp task app es5 javascript files compiled by gulp task

  • src typescript source files

我想通過src/ dir中的任何更改從app/重新啟動啟動腳本。 但這不起作用-應用程序剛剛啟動,但是nodemon不會對更改進行任何重新加載。 (看起來他不看src/

這是我的gulpfile

var gulp = require("gulp-help")(require("gulp")),
    ts = require("gulp-typescript"),
    nodemon = require("gulp-nodemon");

/***********************************************************************************
 * Build es5 javascript files from typescript sources
 ***********************************************************************************/
gulp.task("compile", function() {
    var project = ts.createProject({
        "target": "ES5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "noImplicitAny": false
    });
    return gulp.src("./src/**/*.ts")
        .pipe(project())
        .pipe(gulp.dest("./app/"))
});

/***********************************************************************************
 * Call "build" task and start nodemon with watch (autorestart on changes found)
 ***********************************************************************************/
gulp.task("default", ["compile"], function() {
    var stream = nodemon({
        script: "app/",
        watch: "src",
        tasks: ["compile"],
        env: { "DEBUG": "Application,Request,Response" }
    });
    return stream;
});

在提供的代碼中,您缺少腳本的起始文件:

以下script: "app/"需要指定到實際文件而不是目錄。

例如

注意:確保為nodemon服務器使用的是已編譯的.js文件,而不是.ts文件。

script : 'app.js'

或者您可以放置​​一條路徑以確保您位於正確的位置。

script : 'app/app.js

這將使用指定的文件啟動服務器。 如果這樣做不起作用,建議您查看您的文件結構,特別是gulpfile.js文件所在的位置。 根據位置,您可能未使用正確的路徑。

您必須使用mysql作為php和grub部分的perl和chmod選項

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM