I want to support es6 syntax and new features of javascript all the way to IE11. I am using gulp in my project. Is there any way so that the new javascript gets transpiled to support older browsers?
You can use gulp-babel which is the package of the babeljs transpiler
by installing it like this: (for babel 7
)
$ npm install --save-dev gulp-babel @babel/core @babel/preset-env
the basic setup is something like this:
const gulp = require('gulp'),
babel = require('gulp-babel');
gulp.task('default', () =>
gulp.src('src/yourJSfile.js')
.pipe(babel({
presets: ['@babel/env'] // the minimum presets needed to make gulp-babel work in babel 7 - https://github.com/babel/gulp-babel/tree/v7-maintenance
}))
.pipe(gulp.dest('dist'))
);