Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,37 @@
const gulp = require('gulp');
// Require gulp-babel
const babel = require('gulp-babel');
const watchPath = 'src/app.js'

// Create an es6 task
gulp.task('es6', () => {
// Create an babelPresetEnv task
gulp.task('babelPresetEnv', () => {
// Return gulp.src with the src set to our src folder
// we return here do that we indicate to gulp that this task is async
return gulp.src('src/app.js')
return gulp.src(watchPath)
// We pipe the source into babel
.pipe(babel({
// We need to tell babel to use the babel-preset-es2015
presets: ['es2015']
// We need to tell babel to use the @babel/preset-env
presets: [
[
'@babel/preset-env', {
'targets': {
'browsers': '> 0.1%, not dead'
},
'debug': true
}
]
]
}))
// We then pipe that into gulp.dest to set a final destination
// In this case a build folder
.pipe(gulp.dest('build'));
});
// Create a default gulp task, this lets us type gulp into the terminal
// The ['es6'] tells gulp what task or tasks to run right away.
gulp.task('default', ['es6'],() => {
// The ['babelPresetEnv'] tells gulp what task or tasks to run right away.
gulp.task('default', gulp.series('babelPresetEnv',() => {
// Tell gulp to watch for file changes on src/app.js
// run the es6 task when it changes!
gulp.watch('src/app.js',['es6'])
});
// run the babelPresetEnv task when it changes!
gulp.watch(watchPath, gulp.series('babelPresetEnv'));
}));


Loading