gulp.js Configuration File Source

You can view the full source code for gulpfile.js below.

gulpfile.js

/**
 * Copyright (c) 2026 Andrew G. Johnson <andrew@andrewgjohnson.com>
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * @file The gulp.js configuration file for the agjVersionless jQuery plugin.
 * @copyright 2026 Andrew G. Johnson <andrew@andrewgjohnson.com>
 * @license MIT
 * @see {@link https://github.com/andrewgjohnson/agjVersionless GitHub Repository}
 * @see {@link https://agjVersionless.agjjQuery.org/ Online Documentation}
 * @author Andrew G. Johnson <andrew@andrewgjohnson.com>
 * @version 1.0.0
 */

const babel = require('gulp-babel');
const gulp = require('gulp');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');

/**
 * The transpileCompiled() function down-levels the compiled JavaScript for
 * legacy browser support.
 * @returns - Returns a stream to allow for piping.
 */
const transpileCompiled = function () {
  return gulp
    .src('distribution/jquery.agjVersionless.js')
    .pipe(babel())
    .pipe(gulp.dest('distribution'));
};

/**
 * The minifyCompiled() function will generate jquery.agjVersionless.min.js.
 * @returns - Returns a stream to allow for piping.
 */
const minifyCompiled = function () {
  return gulp
    .src('distribution/jquery.agjVersionless.js')
    .pipe(
      uglify({
        ie8: true,
        output: {
          comments: 'some',
        },
      }),
    )
    .pipe(concat('jquery.agjVersionless.min.js'))
    .pipe(gulp.dest('distribution'));
};

/**
 * Default task that runs all other tasks.
 */
gulp.task(
  'default',
  gulp.series(
    // Down-level distribution/jquery.agjVersionless.js for legacy browsers
    transpileCompiled,

    // Generate jquery.agjVersionless.min.js
    minifyCompiled,
  ),
);