2016-05-17 31 views
1

根據this tutorial的步驟5,當我構建我的項目時,Gulp應將我的node_modules文件夾的內容複製到wwwroot中。未在項目構建中調用Gulp

雖然沒有這樣做。我試過在項目屬性頁面中勾選方框(不知道是否應該改變或不改變)。

tick boxes on project build are ticked

gulpfile.js看起來像這樣:

var ts = require('gulp-typescript'); 
var gulp = require('gulp'); 
var clean = require('gulp-clean'); 

var destPath = './wwwroot/libs/'; 

// Delete the dist directory 
gulp.task('clean', function() { 
    return gulp.src(destPath) 
     .pipe(clean()); 
}); 

gulp.task("scriptsNStyles",() => { 
    gulp.src([ 
      'es6-shim/es6-shim.min.js', 
      'systemjs/dist/system-polyfills.js', 
      'systemjs/dist/system.src.js', 
      'reflect-metadata/Reflect.js', 
      'rxjs/**', 
      'zone.js/dist/**', 
      '@angular/**', 
      'jquery/dist/jquery.*js', 
      'bootstrap/dist/js/bootstrap.*js', 
    ], { 
     cwd: "node_modules/**" 
    }) 
     .pipe(gulp.dest("./wwwroot/libs")); 

    gulp.src([ 
     'node_modules/bootstrap/dist/css/bootstrap.css' 
    ]).pipe(gulp.dest('./wwwroot/libs/css')); 
}); 

var tsProject = ts.createProject('scripts/tsconfig.json'); 
gulp.task('ts', function (done) { 
    //var tsResult = tsProject.src() 
    var tsResult = gulp.src([ 
      "scripts/*.ts" 
    ]) 
     .pipe(ts(tsProject), undefined, ts.reporter.fullReporter()); 
    return tsResult.js.pipe(gulp.dest('./wwwroot/appScripts')); 
}); 

gulp.task('watch', ['watch.ts']); 

gulp.task('watch.ts', ['ts'], function() { 
    return gulp.watch('scripts/*.ts', ['ts']); 
}); 

gulp.task('default', ['scriptsNStyles', 'watch']); 

說實話,我掙扎,調試,因爲我不知道應該做哪些位咕嘟咕嘟地在構建調用做。

任何澄清將是非常有益的。

乾杯

回答

0

似乎在教程中缺少一個步驟。建立項目時,您需要設置綁定來運行Gulp任務。

要做到這一點,打開Task Runner Explorer窗口(查看 - >其他窗口 - >任務運行器資源管理器)。這應該列出您的gulpfile.js中的所有Gulp任務。右鍵單擊想要在構建時運行的那個(可能爲default),然後選擇綁定 - >構建後。您也可以通過右鍵單擊並選擇「運行」來手動運行任務。

Task Runner Explorer Bindings

+0

就是這樣!謝謝。它也錯過了'()=> {...}'不會編譯,並且你需要'scripts'目錄中的'tsconfig.json'來工作。只是添加了這些,一切似乎都很好。 – BanksySan