使用 gulp 复制 .htaccess(点文件)失败
Copy .htaccess (a dotfile) with gulp failed
在 gulp 任务中,我尝试复制构建文件夹中的文件。
gulp.task( addon, function() {
var a_addon_function = addon.split("_") ;
var addon_dirname = a_addon_function[1];
var dest_path = ( options.env === "tests" || ( options.env === "dist" && options.type === "premium" ) ) ? build_path + addon_dirname + "/" + addon_dirname : build_path + addon_dirname;
return gulp.src( [ "./plugins/addons/" + addon_dirname + "/**/*", "./plugins/_common/**/*", "./plugins/addons/_common/**/*" ] )
.pipe( gulp.dest( dest_path )
);
});
永远不会复制文件 .htaccess
。为什么 ?如何解决这个问题?
Gulp 如果我将直接路径添加到此文件,请复制 .htaccess
文件:./plugins/_common/.htaccess
.
gulp.task( addon, function() {
var a_addon_function = addon.split("_") ;
var addon_dirname = a_addon_function[1];
var dest_path = ( options.env === "tests" || ( options.env === "dist" && options.type === "premium" ) ) ? build_path + addon_dirname + "/" + addon_dirname : build_path + addon_dirname;
return gulp.src( [ "./plugins/addons/" + addon_dirname + "/**/*", "./plugins/_common/**/*", "./plugins/_common/.htaccess", "./plugins/addons/_common/**/*" ] )
.pipe( gulp.dest( dest_path )
);
});
可能因为.htaccess
没有得到扩展文件,所以没有复制。
Dots
If a file or directory path portion has a . as the first character,
then it will not match any glob pattern unless that pattern's
corresponding path part also has a . as its first character.
For example, the pattern a/.*/c
would match the file at a/.b/c
.
However the pattern a/*/c
would not, because *
does not start with a
dot character. You can make glob treat dots as normal characters by
setting dot:true in the options.
设置选项:
gulp.src('...…….', { dot: true })
这样点就和其他任何字符一样被对待了。那么你应该可以使用原来的gulp.src。
在 gulp 任务中,我尝试复制构建文件夹中的文件。
gulp.task( addon, function() {
var a_addon_function = addon.split("_") ;
var addon_dirname = a_addon_function[1];
var dest_path = ( options.env === "tests" || ( options.env === "dist" && options.type === "premium" ) ) ? build_path + addon_dirname + "/" + addon_dirname : build_path + addon_dirname;
return gulp.src( [ "./plugins/addons/" + addon_dirname + "/**/*", "./plugins/_common/**/*", "./plugins/addons/_common/**/*" ] )
.pipe( gulp.dest( dest_path )
);
});
永远不会复制文件 .htaccess
。为什么 ?如何解决这个问题?
Gulp 如果我将直接路径添加到此文件,请复制 .htaccess
文件:./plugins/_common/.htaccess
.
gulp.task( addon, function() {
var a_addon_function = addon.split("_") ;
var addon_dirname = a_addon_function[1];
var dest_path = ( options.env === "tests" || ( options.env === "dist" && options.type === "premium" ) ) ? build_path + addon_dirname + "/" + addon_dirname : build_path + addon_dirname;
return gulp.src( [ "./plugins/addons/" + addon_dirname + "/**/*", "./plugins/_common/**/*", "./plugins/_common/.htaccess", "./plugins/addons/_common/**/*" ] )
.pipe( gulp.dest( dest_path )
);
});
可能因为.htaccess
没有得到扩展文件,所以没有复制。
Dots
If a file or directory path portion has a . as the first character, then it will not match any glob pattern unless that pattern's corresponding path part also has a . as its first character.
For example, the pattern
a/.*/c
would match the file ata/.b/c
. However the patterna/*/c
would not, because*
does not start with a dot character. You can make glob treat dots as normal characters by setting dot:true in the options.
设置选项:
gulp.src('...…….', { dot: true })
这样点就和其他任何字符一样被对待了。那么你应该可以使用原来的gulp.src。