gulpfile.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const gulp = require('gulp'),
  2. sass = require('gulp-sass'),
  3. rename = require("gulp-rename"),
  4. concat = require("gulp-concat"),
  5. purgeCSS = require('gulp-purgecss'),
  6. sourcemaps = require('gulp-sourcemaps');
  7. purgeSourcemaps = require('gulp-purge-sourcemaps');
  8. browserSync = require('browser-sync').create();
  9. gulp.task('copy', async function() {
  10. gulp.src([
  11. './node_modules/bootstrap/dist/js/bootstrap.bundle.js',
  12. './node_modules/jasny-bootstrap/dist/js/jasny-bootstrap.js'
  13. ])
  14. .pipe(sourcemaps.init({loadMaps: true}))
  15. .pipe(purgeSourcemaps())
  16. .pipe(gulp.dest('./js/'));
  17. gulp.src([
  18. './node_modules/bootstrap/dist/css/bootstrap.css',
  19. './node_modules/bootstrap-icons/font/bootstrap-icons.css',
  20. './node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.css'
  21. ])
  22. .pipe(sourcemaps.init({loadMaps: true}))
  23. .pipe(purgeSourcemaps())
  24. .pipe(gulp.dest('./css/'));
  25. gulp.src([
  26. './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff',
  27. './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2'
  28. ])
  29. .pipe(gulp.dest('./css/fonts/'));
  30. console.log("files 📄 copied from npm pkgs ");
  31. });
  32. gulp.task('build', async function() {
  33. console.log("Assets built 🔧");
  34. });
  35. function mixin() {
  36. return gulp.src('./css/_scss/**/*.scss')
  37. .pipe(sass().on('error',sass.logError))
  38. .pipe(gulp.dest('./css/'))
  39. .pipe(browserSync.stream());
  40. }
  41. function run() {
  42. browserSync.init({
  43. proxy: 'https://macs.local/hp',
  44. host: 'a.macs',
  45. open: 'external',
  46. port: 8888,
  47. https: true
  48. });
  49. gulp.watch('./css/*.scss', mixin);
  50. gulp.watch('./css/*.css').on('change', browserSync.reload);
  51. gulp.watch('./js/**/*.js').on('change', browserSync.reload);
  52. }
  53. exports.mixin = mixin;
  54. exports.run = run;