【发布时间】:2015-05-31 16:28:11
【问题描述】:
Visual Studio 2015 ASP.NET 5 模板,以 gulpfile.js 和几个已安装的 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.
【问题讨论】:
-
./ext_modules/dist未在您的屏幕截图中展开,我不知道其中有哪些文件...您是否也打算将所有文件包含在./ext_modules/dist的子文件夹中? ("ext-modules": "dist/**/*.{js,map,css,ttf,svg,woff,eot}") -
dist 仅包含 2 个文件。一个js和css文件。没有文件夹。我也试过 ** 语法。
-
哎哟。我的下一个建议是从命令行运行它,但既然它现在可以工作了......你有没有通过手表触发它?我知道可以缓存...
标签: gulp bower asp.net-core