[英]Gulp copy directory over and files
I have a directory setup like this: 我有一个像这样的目录设置:
I'm trying to copy these to a dist folder like this: 我正在尝试将这些复制到这样的dist文件夹:
I've tried a number of variations, such as 我尝试了很多变化,比如
gulp.src(['src/**/*', 'node_modules/**']).pipe(gulp.dest('dist'));
But this places all of the node_modules in the /dist and not within the node_modules directory. 但是这会将所有node_modules放在/ dist中,而不是在node_modules目录中。
Any idea how I can do this? 知道我怎么能这样做吗?
You need to tell gulp.src
that the base directory for node_modules/**
is .
你需要告诉
gulp.src
node_modules/**
的基目录.
so that the node_modules
created at the destination. 以便在目的地创建
node_modules
。 However, you cannot set the base to .
但是,您无法将基数设置为
.
for src/**/*
because that would mean that the src
directory would be created in your destination. 对于
src/**/*
因为这意味着将在目标中创建src
目录。 So you need in effect to specify two sets of sources. 因此,您需要指定两组源。
gulp-add-src
can help with this. gulp-add-src
可以帮助解决这个问题。
Something like this should work: 这样的事情应该有效:
var addsrc = require("gulp-add-src");
gulp.src('src/**/*')
.pipe(addsrc('node_modules/**', { base: '.'})
.pipe(gulp.dest('dist'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.