gulpfile.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. const gulp = require('gulp'),
  2. concat = require('gulp-concat'),
  3. sass = require('gulp-sass');
  4. browserSync = require('browser-sync').create();
  5. function copy(cb) {
  6. gulp.src([
  7. './node_modules/bootstrap/dist/js/bootstrap.bundle.min.js',
  8. './node_modules/bootstrap/dist/js/bootstrap.bundle.min.js.map'
  9. ])
  10. .pipe(gulp.dest('./js/'));
  11. gulp.src([
  12. './node_modules/bootstrap/dist/css/bootstrap.min.css',
  13. './node_modules/bootstrap/dist/css/bootstrap.min.css.map',
  14. './node_modules/bootstrap-icons/font/bootstrap-icons.css'
  15. ])
  16. .pipe(gulp.dest('./css/'));
  17. gulp.src([
  18. './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff',
  19. './node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2',
  20. ])
  21. .pipe(gulp.dest('./css/fonts/'));
  22. console.log("Copy assets ๐Ÿ“ฆ ");
  23. cb();
  24. }
  25. function build(cb) {
  26. gulp.src([
  27. './css/bootstrap-icons.css',
  28. './css/bootstrap.min.css',
  29. './css/styles.css',
  30. ])
  31. .pipe(concat('site.css'))
  32. .pipe(gulp.dest('./css/'));
  33. gulp.src([
  34. './js/bootstrap.bundle.min.js',
  35. ])
  36. .pipe(concat('site.js'))
  37. .pipe(gulp.dest('./js/'));
  38. console.log("Assets built ๐Ÿ”ง ");
  39. cb();
  40. }
  41. function clean (cb) {
  42. gulp.src('./css/site.css')
  43. .pipe(cleanCSS({level: {1: {specialComments: 0}}}))
  44. .pipe(gulp.dest('./css/'));
  45. console.log("CSS cleaned ๐Ÿงน ");
  46. cb();
  47. }
  48. function mixin() {
  49. return src('./css/*.scss', { sourcemaps: true })
  50. .pipe(sass().on('error',sass.logError))
  51. .pipe(gulp.dest('./css/'))
  52. .pipe(browserSync.stream());
  53. }
  54. function reload(cb) {
  55. browserSync.reload();
  56. cb();
  57. }
  58. function run() {
  59. browserSync.init({
  60. server: {
  61. baseDir: "./",
  62. index: "/index.html"
  63. }
  64. });
  65. gulp.watch('./css/*.scss', mixin);
  66. gulp.watch('./*.html', reload);
  67. gulp.watch([
  68. './css/site.css',
  69. './js/site.js'
  70. ]).on('change',browserSync.reload);
  71. console.log("๐Ÿ”ฅ Run");
  72. }
  73. exports.copy = copy;
  74. exports.build = build;
  75. exports.clean = clean;
  76. exports.mixin = mixin;
  77. exports.run = run;