Visual Studio 2015 ASP.NET 5模板,以gulpfile.js和几个已安装的bower组件开头。我添加了额外的bower组件(angularjs),并按预期将它们复制到我的wwwroot \ lib文件夹中。我已将我自己的一个库添加到一个名为ext_modules \ dist的文件夹中。我正在向gulpfile.js添加一个任务,以便将我的文件(包含单个.js和.css文件)复制到wwwroot \ lib文件夹中。我正在遵循gulpfile.js中已经存在的示例语法。但是,从我的ext_modules文件夹中没有复制任何内容。请参阅下面的JS,输出和文件夹结构。
/// <binding Clean='clean' />
var gulp = require("gulp"),
rimraf = require("rimraf"),
fs = require("fs");
eval("var project = " + fs.readFileSync("./project.json"));
var paths = {
bower: "./bower_components/",
extmodules: "./ext_modules/",
lib: "./" + project.webroot + "/lib/"
};
gulp.task("clean", function (cb) {
rimraf(paths.lib, cb);
});
gulp.task("copy", ["clean"], function () {
var bower = {
"angular": "angular.js/*.js",
"bootstrap": "bootstrap/dist/**/*.{js,map,css,ttf,svg,woff,eot}",
"bootstrap-touch-carousel": "bootstrap-touch-carousel/dist/**/*.{js,css}",
"hammer.js": "hammer.js/hammer*.{js,map}",
"jquery": "jquery/jquery*.{js,map}",
"jquery-validation": "jquery-validation/jquery.validate.js",
"jquery-validation-unobtrusive": "jquery-validation-unobtrusive/jquery.validate.unobtrusive.js",
};
var extmodules = {
"ext-modules": "dist/*.{js,map,css,ttf,svg,woff,eot}"
};
for (var module in bower) { /* This copy works fine*/
console.log("Source: " + paths.bower + bower[module]);
console.log("Destination: " + paths.lib + module);
gulp.src(paths.bower + bower[module])
.pipe(gulp.dest(paths.lib + module));
};
for (var module in extmodules) { /* This does not copy any files */
console.log("Source: " + paths.extmodules + extmodules[module]);
console.log("Destination: " + paths.lib + module);
gulp.src(paths.extmodules + extmodules[module])
.pipe(gulp.dest(paths.lib + module));
};
});
这是我的控制台日志:
[11:17:57] Starting 'clean'...
[11:17:57] Finished 'clean' after 11 ms
[11:17:57] Starting 'copy'...
Source: ./bower_components/angular.js/*.js
Destination: ./wwwroot/lib/angular
Source: ./bower_components/bootstrap/dist/**/*.{js,map,css,ttf,svg,woff,eot}
Destination: ./wwwroot/lib/bootstrap
Source: ./bower_components/bootstrap-touch-carousel/dist/**/*.{js,css}
Destination: ./wwwroot/lib/bootstrap-touch-carousel
Source: ./bower_components/hammer.js/hammer*.{js,map}
Destination: ./wwwroot/lib/hammer.js
Source: ./bower_components/jquery/jquery*.{js,map}
Destination: ./wwwroot/lib/jquery
Source: ./bower_components/jquery-validation/jquery.validate.js
Destination: ./wwwroot/lib/jquery-validation
Source: ./bower_components/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js
Destination: ./wwwroot/lib/jquery-validation-unobtrusive
Source: ./ext_modules/dist/*.{js,map,css,ttf,svg,woff,eot}
Destination: ./wwwroot/lib/ext-modules
[11:17:57] Finished 'copy' after 21 ms
Process terminated with code 0.
答案 0 :(得分:1)
如果我在gulpfile.js上明确地右键鼠标并选择&#34; Task Runner Explorer&#34;我可以让它工作。然后一个窗口显示停靠在底部。在任务中将是一个任务列表。然后,您可以右键单击要运行的任务,然后选择&#34;运行&#34;。