1
根據this tutorial的步驟5,當我構建我的項目時,Gulp應將我的node_modules
文件夾的內容複製到wwwroot
中。未在項目構建中調用Gulp
雖然沒有這樣做。我試過在項目屬性頁面中勾選方框(不知道是否應該改變或不改變)。
的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']);
說實話,我掙扎,調試,因爲我不知道應該做哪些位咕嘟咕嘟地在構建調用做。
任何澄清將是非常有益的。
乾杯
就是這樣!謝謝。它也錯過了'()=> {...}'不會編譯,並且你需要'scripts'目錄中的'tsconfig.json'來工作。只是添加了這些,一切似乎都很好。 – BanksySan