How to avoid duplication of code in the script after the concatenation?

Hi!
I want to write a script that will:
Take all the files in js and pass it through babel and to do a reload of the page. But when you run Tasca gulp js code concatenated as many times as we called task gulp js.
What I need to do to stop this from happening?
My code
const gulp = require('gulp'),
 browserSync = require('browser-sync'),
 sourcemaps = require('gulp-sourcemaps'),
 babel = require('gulp-babel'),
 rename = require('gulp-rename'),
 concat = require('gulp-concat');

gulp.task('js', () => {
 return gulp.src('app/src/**/*.js') // Take all files in the specified directory
 .pipe(concat('bundle.hello.js')) // Concatenate everything into a single file
 .pipe(gulp.dest('app/src/js')) // Placed in the specified directory
.pipe(browserSync.stream());
});

// babel
gulp.task('babel', () => {
 return gulp.src('app/src/js/bundle.hello.js') // Take the file
 .pipe(babel({ // Skip code via babel
 presets: ['babel-preset-env'],
}))
 .pipe(rename('hello.js')) // Rename and create a new file with the changes
 .pipe(gulp.dest('app/src')) // Put it in daddy
.pipe(browserSync.stream());
});

gulp.task('serve', ['sass', 'babel'], () => { // Start the server
browserSync({
 server: {
 baseDir: 'app',
},
 notify: false,
});
 gulp.watch('app/sass/*.sass', ['sass']); 
 gulp.watch('app/src/*.js', ['js']).on('change', browserSync.reload);
gulp.watch('app/src/**/*.js');
 gulp.watch('app/*.html').on('change', browserSync.reload);
});
June 10th 19 at 16:01
0 answer

Find more questions by tags Gulp.jsJavaScript