Visual Studio 2015 ASP.NET 5, Gulp task not copying files from node_modules

本秂侑毒 提交于 2019-12-18 12:16:49

问题


I am attempting to alter a task runner script that I borrowed from here, however; after the task runner successfully executes in Visual Studio 2015's Task Runner Explorer -- the files are not actually copied.

Here is the altered script:

/// <binding BeforeBuild='copy-assets' />
"use strict";

var _    = require('lodash'),
    gulp = require('gulp');

gulp.task('copy-assets', function() {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js',
            './node_modules/systemjs/dist/system.src.js',
            './node_modules/angular2/bundles/angular2.dev.js',
            './node_modules/angular2/bundles/router.dev.js',
            './node_modules/angular2/bundles/angular2-polyfills.js',
            './node_modules/angular2/bundles/http.dev.js',
            './node_modules/rxjs/bundles/Rx.js',
            './node_modules/typescript/lib/typescript.js'
        ],
        css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
    };
    _(assets).forEach(function(assets, type) {
        gulp.src(assets).pipe(gulp.dest('./webroot/' + type));
    });
});

The task runner seems to run without error in Visual Studio 2015 Enterprise, but there are no files in my wwwroot/js or wwwroot/css afterwards?

Here is the file structure:

What am I doing wrong and how do I fix this? Any and all help is much appreciated!


回答1:


Minor oversight... unfortunately gulp silently creates the directory webroot and copies the files into it, it should be wwwroot. Oops!!

/// <binding BeforeBuild='copy-assets' />
"use strict";

var _    = require('lodash'),
    gulp = require('gulp');

gulp.task('copy-assets', function() {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js',
            './node_modules/systemjs/dist/system.src.js',
            './node_modules/angular2/bundles/angular2.dev.js',
            './node_modules/angular2/bundles/router.dev.js',
            './node_modules/angular2/bundles/angular2-polyfills.js',
            './node_modules/angular2/bundles/http.dev.js',
            './node_modules/rxjs/bundles/Rx.js',
            './node_modules/typescript/lib/typescript.js'
        ],
        css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
    };
    _(assets).forEach(function(assets, type) {
        gulp.src(assets).pipe(gulp.dest('./wwwroot/' + type));
    });
});

:punch:



来源:https://stackoverflow.com/questions/34636570/visual-studio-2015-asp-net-5-gulp-task-not-copying-files-from-node-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!