I am trying to merge my JS files and run them through Babel for a new project, but instead of overwriting the destination file each time the task starts, my gulpfile only adds the changes to the file. So my destination file is as follows:
console.log('hello'); //
What am I missing? Below is my gulpfile.
Thanks in advance.
var gulp = require('gulp'); var sourcemaps = require("gulp-sourcemaps"); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); var concat = require('gulp-concat'); var babel = require('gulp-babel'); var browserSync = require('browser-sync').create(); var reload = browserSync.reload; gulp.task('js', function(){ return gulp.src("./app/js/*.js") .pipe(sourcemaps.init()) .pipe(concat("app.js")) .pipe(babel()) .pipe(sourcemaps.write(".")) .pipe(gulp.dest("./app/js/")); }); gulp.task('js-reload', ['js'], reload); gulp.task('serve', ['js'], function() { browserSync.init({ server: "./app" }); gulp.watch("./app/js/*.js").on('change', ['js-reload']); gulp.watch("./app/*.html").on('change', reload); }); gulp.task('default', ['js', 'serve']);
source share