在VS2015 Task Runner Explorer中运行gulp文件失败

时间:2016-09-01 05:17:53

标签: visual-studio-2015 gulp

我正在关注Chris Sakell的this教程,以期获得一个使用AngularJs 2的SPA。

按照指示,我创建了gulp文件 - 根目录中的gulp.js和webroot目录中的tsconfig.json文件。

我安装了npm以及gulp,因为这是初始过程的一部分。

我认为这个想法是在wwwroot文件夹下创建和填充目录,包括" lib"和" app"。

我尝试使用VS2015中的Task Runner Explorer来运行它,特别是点击" build-spa"在左边,我得到了:

    :\Users\simon\SPA\CHASAKELL-SCRATCH\PhotoGallery\src\PhotoGallery\Gulpfile.js" build-spa
[14:27:12] Using gulpfile ~\SPA\CHASAKELL-SCRATCH\PhotoGallery\src\PhotoGallery\Gulpfile.js
[14:27:12] Starting 'setup-vendors'...
[14:27:12] Starting 'compile-typescript'...
[14:27:12] Finished 'compile-typescript' after 20 ms
Process terminated with code 0.

没有创建wwroot下的文件,似乎没有创建任何文件。这些文件有什么问题,或者在VS2015中成功运行gulp.js文件的过程中,我有没有做过什么?

编辑:好的,所以我跑了" gulp build-spa"从命令窗口开始工作......那为什么它在VS2015中不起作用?

tsconfig.json文件如下:

{
"compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": false,
    "noImplicitAny": false,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5"
},
"exclude": [
    "node_modules/**/*.d.ts",
    "wwwroot",
    "typings/main",
    "typings/main.d.ts"
]
}

gulp.js文件是:

        var gulp = require('gulp'),
        ts = require('gulp-typescript'),
        merge = require('merge'),
        fs = require("fs"),
        del = require('del'),
        path = require('path');

    eval("var project = " + fs.readFileSync("./project.json"));
    var lib = "./" + project.webroot + "/lib/";

    var paths = {
        npm: './node_modules/',
        tsSource: './wwwroot/app/**/*.ts',
        tsOutput: lib + 'spa/',
        tsDef: lib + 'definitions/',
        jsVendors: lib + 'js',
        jsRxJSVendors: lib + 'js/rxjs',
        cssVendors: lib + 'css',
        imgVendors: lib + 'img',
        fontsVendors: lib + 'fonts'
    };


    var tsProject = ts.createProject('./wwwroot/tsconfig.json');

    gulp.task('setup-vendors', function (done) {
        gulp.src([
          'node_modules/jquery/dist/jquery.*js',
          'bower_components/bootstrap/dist/js/bootstrap*.js',
          'node_modules/fancybox/dist/js/jquery.fancybox.pack.js',
          'bower_components/alertify.js/lib/alertify.min.js',
          'systemjs.config.js'
        ]).pipe(gulp.dest(paths.jsVendors));

        gulp.src([
          'bower_components/bootstrap/dist/css/bootstrap.css',
          'node_modules/fancybox/dist/css/jquery.fancybox.css',
          'bower_components/components-font-awesome/css/font-awesome.css',
          'bower_components/alertify.js/themes/alertify.core.css',
          'bower_components/alertify.js/themes/alertify.bootstrap.css',
          'bower_components/alertify.js/themes/alertify.default.css'
        ]).pipe(gulp.dest(paths.cssVendors));

        gulp.src([
          'node_modules/fancybox/dist/img/blank.gif',
          'node_modules/fancybox/dist/img/fancybox_loading.gif',
          'node_modules/fancybox/dist/img/fancybox_loading@2x.gif',
          'node_modules/fancybox/dist/img/fancybox_overlay.png',
          'node_modules/fancybox/dist/img/fancybox_sprite.png',
          'node_modules/fancybox/dist/img/fancybox_sprite@2x.png'
        ]).pipe(gulp.dest(paths.imgVendors));

        gulp.src([
          'node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot',
          'node_modules/bootstrap/fonts/glyphicons-halflings-regular.svg',
          'node_modules/bootstrap/fonts/glyphicons-halflings-regular.ttf',
          'node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff',
          'node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff2',
          'bower_components/components-font-awesome/fonts/FontAwesome.otf',
          'bower_components/components-font-awesome/fonts/fontawesome-webfont.eot',
          'bower_components/components-font-awesome/fonts/fontawesome-webfont.svg',
          'bower_components/components-font-awesome/fonts/fontawesome-webfont.ttf',
          'bower_components/components-font-awesome/fonts/fontawesome-webfont.woff',
          'bower_components/components-font-awesome/fonts/fontawesome-webfont.woff2',
        ]).pipe(gulp.dest(paths.fontsVendors));
    });

    gulp.task('compile-typescript', function (done) {
        var tsResult = gulp.src([
           "wwwroot/app/**/*.ts"
        ])
         .pipe(ts(tsProject), undefined, ts.reporter.fullReporter());
        return tsResult.js.pipe(gulp.dest(paths.tsOutput));
    });

    gulp.task('watch.ts', ['compile-typescript'], function () {
        return gulp.watch('wwwroot/app/**/*.ts', ['compile-typescript']);
    });

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

    gulp.task('clean-lib', function () {
        return del([lib]);
    });

    gulp.task('build-spa', ['setup-vendors', 'compile-typescript']);

0 个答案:

没有答案