[英]Gulp: Exclude src root folder when outputting to dest folder
Given the following gulpfile, I would expect the contents of the dist
folder to be the contents of src/js/
. 给定以下gulpfile,我希望dist
文件夹的内容是src/js/
的内容。 Instead, the contents of dist
is src/js/*
. 相反, dist
的内容是src/js/*
。
var del = require('del');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var livereload = require('gulp-livereload');
var notify = require('gulp-notify');
var sourcemaps = require('gulp-sourcemaps');
var transpile = require('gulp-es6-module-transpiler');
gulp.task('build', function() {
return gulp.src('src/js/**/*.js')
.pipe(sourcemaps.init())
.pipe(transpile({
formatter: 'bundle'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
.pipe(notify({ message: 'Build task complete.' })); });
How do I exclude the src
root directory from the dist
output directory, such that the result would be dist/js/**/*.js
如何从dist
输出目录中排除src
根目录,使得结果为dist/js/**/*.js
My guess is that it's to do with relative paths (compared to where you run gulp from). 我的猜测是,它与相对路径有关(与运行gulp的位置相比)。 Try changing the dest to a relative path: 尝试将目标更改为相对路径:
gulp.task('build', function() {
return gulp.src('./src/js/**/*.js')
.pipe(sourcemaps.init())
.pipe(transpile({
formatter: 'bundle'
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/js/'))
.pipe(notify({ message: 'Build task complete.' })); });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.