/*
 * Blue Twilight Gulp build file
 */

var gulp = require('gulp-help')(require('gulp'));

// Dependencies
var concat = require('gulp-concat');
var uglify = require('gulp-uglify-es').default;
var uglifyCss = require('gulp-uglifycss');

var cssFiles = [
        'resources/assets/css/**/*.css',
        'resources/assets/bootstrap/css/bootstrap.css',
        'resources/assets/font-awesome/css/font-awesome.css',
        'resources/assets/selectize/css/selectize.css',
        'resources/assets/selectize/css/selectize.bootstrap3.css'
    ],
    cssDest = 'public/css';

var jsFiles = [
        'resources/assets/js/**/*.js',
        'resources/assets/popper-js/popper.js',
        'resources/assets/popper-js/popper-utils.js',
        'resources/assets/bootstrap/js/bootstrap.js',
        'resources/assets/selectize/js/standalone/selectize.js'
    ],
    jsDest = 'public/js';

var fontsFiles = 'resources/assets/font-awesome/fonts/**/*',
    fontsDest = 'public/fonts';

gulp.task('bt-assets-css', function() {
    return gulp.src(cssFiles)
        .pipe(concat('blue-twilight.css'))
        .pipe(gulp.dest(cssDest));
});

gulp.task('bt-assets-css-min', ['bt-assets-css'], function() {
    return gulp.src(cssFiles)
        .pipe(concat('blue-twilight.min.css'))
        .pipe(uglifyCss())
        .pipe(gulp.dest(cssDest));
});

gulp.task('bt-assets-js', function() {
    return gulp.src(jsFiles)
        .pipe(concat('blue-twilight.js'))
        .pipe(gulp.dest(jsDest));
});

gulp.task('bt-assets-js-min', ['bt-assets-js'], function() {
    return gulp.src(jsFiles)
        .pipe(concat('blue-twilight.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest(jsDest));
});

gulp.task('bt-assets-fonts', function() {
    return gulp.src(fontsFiles)
        .pipe(gulp.dest(fontsDest));
});

gulp.task('bt-assets', false, [
    'bt-assets-css-min',
    'bt-assets-js-min',
    'bt-assets-fonts'
]);