I am currently developing a JavaScript library and my goal is to transpile all ES6 code to the ES5 standard in order to increase browser support.
To achieve this, I have decided to utilize Babel with Gulp tasks. In preparation, I have installed the necessary NPM packages listed in my package.json
:
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"babel-cli": "^6.26.0",
"gulp": "^3.9.1",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-terser": "^1.1.5"
}
In addition, my .babelrc
file contains the following presets:
{
"presets": ["env"]
}
The contents of my gulpfile.js
are as follows:
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const terser = require('gulp-terser');
gulp.task('minify', function () {
return gulp.src('src/app/classes/*.js')
.pipe(sourcemaps.init())
.pipe(babel()) // No need to pass preset since it's specified in .babelrc
.pipe(concat('output.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('build/js'))
});
gulp.task('default', ['minify']);
However, when I run the gulp
command from the project root directory, no output file is generated. Despite receiving a successful execution message in the console, nothing appears in the build/js
directory or any other part of the project.
#user1:/project-route$> gulp
[17:36:54] Using gulpfile /project-route/gulpfile.js
[17:36:54] Starting 'minify'...
Even after attempting to remove the sourcemaps
functions, the issue persists - still, nothing gets produced!