只复制Gulp根目录中的文件

时间:2018-06-30 17:51:49

标签: javascript html gulp

我正在尝试仅从根目录而非子文件夹复制所有文件。目前,这就是我的任务。

const dev = 'app';

const dist = 'dist';

const htmlDev = `${dev}`;
const htmlDist = `${dist}`;

const sassDev = `${dev}/scss`;
const sassDist = `${dist}/css`;

const jsDev = `${dev}/js`;
const jsDist = `${dist}/js`;

const tplDev = `${dev}/template-parts`;
const tplDist = `${dist}/template-parts`;

gulp.task('copyfiles', () => {
  console.log(`Copying files now`);
  gulp.src('app/*.+(php|css|png|txt|md|dist|html)')
    .pipe(gulp.dest(htmlDist));
});

如何简化此过程以使任务正常运行?

1 个答案:

答案 0 :(得分:0)

如果您要使用目录中的所有文件,请使用:

julia> using BenchmarkTools

julia> f(;a::Int=1) = [a]
f (generic function with 1 method)

julia> g(a::Int=1) = [a]
g (generic function with 2 methods)

julia> h(;a=1) = [a]
h (generic function with 1 method)

julia> @benchmark f()
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.724 ns (0.00% GC)
  median time:      34.523 ns (0.00% GC)
  mean time:        50.576 ns (22.80% GC)
  maximum time:     53.465 μs (99.89% GC)
  --------------
  samples:          10000
  evals/sample:     1000

julia> @benchmark f(a=10)
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.724 ns (0.00% GC)
  median time:      34.057 ns (0.00% GC)
  mean time:        50.739 ns (22.83% GC)
  maximum time:     55.303 μs (99.89% GC)
  --------------
  samples:          10000
  evals/sample:     1000

julia> @benchmark g()
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.724 ns (0.00% GC)
  median time:      34.523 ns (0.00% GC)
  mean time:        50.529 ns (22.77% GC)
  maximum time:     54.501 μs (99.89% GC)
  --------------
  samples:          10000
  evals/sample:     1000

julia> @benchmark g(10)
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.724 ns (0.00% GC)
  median time:      34.523 ns (0.00% GC)
  mean time:        50.899 ns (23.27% GC)
  maximum time:     56.246 μs (99.90% GC)
  --------------
  samples:          10000
  evals/sample:     1000

julia> @benchmark h()
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.257 ns (0.00% GC)
  median time:      34.057 ns (0.00% GC)
  mean time:        50.924 ns (22.87% GC)
  maximum time:     55.724 μs (99.88% GC)
  --------------
  samples:          10000
  evals/sample:     1000

julia> @benchmark h(a=10)
BenchmarkTools.Trial:
  memory estimate:  96 bytes
  allocs estimate:  1
  --------------
  minimum time:     31.724 ns (0.00% GC)
  median time:      34.057 ns (0.00% GC)
  mean time:        50.864 ns (22.60% GC)
  maximum time:     53.389 μs (99.83% GC)
  --------------
  samples:          10000
  evals/sample:     1000

将不包含子目录。我添加了return gulp.src('app/*.*') ,因为您迟早可能会需要它。顺便说一句,如果您想要所有子目录,可以使用:

return