Reputation: 14189
I have created a task in gulp to transpile my nodejs app:
gulp.task('babel', function() {
return gulp.src('./**/*.js')
.pipe(babel({
ignore: [
'./gulpfile.js',
'./node_modules/**/*.js',
]
}))
.pipe(gulp.dest('./dist'));
});
the problem is that during the transpiling the node_modules folder and gulpfile are created in the dist folder. any idea why?
gulpfile
var gulp = require('gulp');
var babel = require('gulp-babel');
var nodemon = require('gulp-nodemon');
gulp.task('babel', function() {
return gulp.src([
'./**/*.js',
'./server/config/manifest.' + (process.env['NODE_ENV'] || 'development') + '.json',
'!./gulpfile.js',
'!./node_modules/**/*.js'
])
.pipe(babel())
.pipe(gulp.dest('./dist'));
});
gulp.task('start', ['babel'], function() {
nodemon({
script: './dist/server.js',
ext: 'js jsx',
tasks: ['babel']
});
});
gulp.task('default', ['start']);
Upvotes: 0
Views: 3150
Reputation: 26797
Babel's ignore
just means they won't be transformed, but with that config gulp is still going to pipe them through. You probably want those patterns in an ignore
option to gulp.src
.
Edit: actually I forgot that the ability to exclude those patterns by passing an ignore
option to gulp.src
depends on how recent your glob
version is (see my bug report). An alternative is the !
negated patterns @raina77ow suggested.
Upvotes: 2