const gulp = require("gulp"),
  concat = require('gulp-concat'),
  del = require('del'),
  sass = require('gulp-sass')(require('sass')),
  rename = require("gulp-rename"),
  uglify = require('gulp-uglify');

const bundles = {
  jfa: {
    outputFileName: "wwwroot/dist/js/jfa.js",
    inputFiles: [
      "Assets/js/_Jfa.js",
      "Assets/js/Page/_Page.js",
      "Assets/js/Utilities/Routing/_Routing.js",
      "Assets/js/Utilities/Element/_Element.js",
      "Assets/js/Utilities/Request/_Request.js",
      "Assets/js/Components/Dialog/_Dialog.js"
    ]
  },
};

gulp.task('bundle:jfa', function () {
  return gulp.src(bundles.jfa.inputFiles, { base: "." })
    .pipe(concat(bundles.jfa.outputFileName))
    .pipe(gulp.dest("."))
    .pipe(uglify())
    .pipe(rename({ suffix: '.min' }))
    .pipe(gulp.dest("."));
});

gulp.task('default', gulp.series(
  gulp.parallel(['bundle:jfa'])
));