const gulp = require('gulp'), useref = require('gulp-useref'), gulpif = require('gulp-if'), uglify = require('gulp-uglify'), sass = require('gulp-sass'), cleanCSS = require('gulp-clean-css'), rename = require("gulp-rename"), concat = require("gulp-concat"), browserSync = require('browser-sync').create(); gulp.task('copyjs', async function() { gulp.src('./node_modules/bootstrap/dist/js/bootstrap.js') .pipe(gulp.dest('./js/')); gulp.src('./node_modules/jquery/dist/jquery.min.js') .pipe(gulp.dest('./js/')); console.log("files 📄 from npm pkgs "); }); gulp.task('build', async function() { gulp.src('index.html') .pipe(useref()) .pipe(gulpif('*.js', uglify())) .pipe(gulpif('*.css', cleanCSS({level: {1: {specialComments: 0}}}))) .pipe(gulp.dest('./app/')); console.log("Assets built 🔧 for app/ "); }); function mixin() { return gulp.src('./css/_scss/**/*.scss') .pipe(sass().on('error',sass.logError)) .pipe(gulp.dest('./css/')) .pipe(browserSync.stream()); } function run() { browserSync.init({ server: { baseDir: "./", index: "/index.html" } }); gulp.watch('./css/_scss/*.scss', mixin); gulp.watch('./css/**/*.css').on('change', browserSync.reload); gulp.watch('./*.html').on('change',browserSync.reload); gulp.watch('./js/**/*.js').on('change', browserSync.reload); } exports.mixin = mixin; exports.run = run;