鉴于以下gulpfile,我希望dist
文件夹的内容是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.' })); });
如何从src
输出目录中排除dist
根目录,结果为dist/js/**/*.js
答案 0 :(得分:1)
我的猜测是它与相对路径有关(与你从哪里开始吞咽)。尝试将dest更改为相对路径:
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.' })); });