gulpfile.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. const gulp = require('gulp'),
  2. concat = require("gulp-concat"),
  3. rename = require("gulp-rename"),
  4. cleanCSS = require('gulp-clean-css'),
  5. uglify = require('gulp-uglify'),
  6. terser = require('gulp-terser'),
  7. sass = require('gulp-sass')(require('sass')),
  8. streamqueue = require('streamqueue');
  9. browserSync = require('browser-sync').create();
  10. function copy(cb) {
  11. gulp.src('./node_modules/bootstrap/dist/js/bootstrap.bundle.js')
  12. .pipe(rename('v4-bootstrap.js'))
  13. .pipe(gulp.dest('./js/'));
  14. gulp.src('./node_modules/bootstrap/dist/js/bootstrap.bundle.js.map')
  15. .pipe(gulp.dest('./js/'));
  16. gulp.src('./node_modules/jquery/dist/jquery.min.js')
  17. .pipe(rename('v4-jquery.js'))
  18. .pipe(gulp.dest('./js/'));
  19. gulp.src('./node_modules/animate.css/animate.css')
  20. .pipe(rename('v4-animate.css'))
  21. .pipe(gulp.dest('./css/'));
  22. gulp.src('./node_modules/svg-morpheus/compile/minified/svg-morpheus.js')
  23. .pipe(rename('v4-svg-morpheus.js'))
  24. .pipe(gulp.dest('./js/'));
  25. gulp.src('./node_modules/fullcalendar/main.js')
  26. .pipe(rename('v4-fullcalendar.js'))
  27. .pipe(gulp.dest('./js/', { overwrite:true } ));
  28. gulp.src('./node_modules/fullcalendar/main.css')
  29. .pipe(rename('v4-fullcalendar.css'))
  30. .pipe(gulp.dest('./css/', { overwrite:true } ));
  31. console.log("files 📄 from npm pkgs ");
  32. cb();
  33. }
  34. function build(cb) {
  35. return streamqueue({ objectMode: true },
  36. gulp.src('./css/fonts.css'),
  37. gulp.src('./css/v4-animate.css'),
  38. gulp.src('./css/v4-fullcalendar.css'),
  39. gulp.src('./css/styles.css'),
  40. gulp.src('./style.css')
  41. )
  42. .pipe(concat('v4-style.css'))
  43. .pipe(cleanCSS({level: {1: {specialComments: 0}}}))
  44. .pipe(rename('v4-style.min.css'))
  45. .pipe(gulp.dest('./', { overwrite:true })),
  46. console.log("Build 🔧 "),
  47. cb();
  48. }
  49. function cssf(cb) {
  50. gulp.src('css/front-page.css')
  51. .pipe(cleanCSS({level: {1: {specialComments: 0}}}))
  52. .pipe(rename('v4-front.min.css'))
  53. .pipe(gulp.dest('./css/', { overwrite:true })),
  54. console.log("CSS Front built 🔧 "),
  55. cb();
  56. }
  57. function js(cb) {
  58. return streamqueue({ objectMode: true },
  59. gulp.src('./js/v4-jquery.js'),
  60. gulp.src('./js/v4-bootstrap.js'),
  61. gulp.src('./js/v4-fullcalendar.js'),
  62. gulp.src('./js/modernizr.js'),
  63. gulp.src('./js/validate.js'),
  64. gulp.src('./js/scripts.js')
  65. )
  66. .pipe(terser({ output: {comments: false} }))
  67. .pipe(concat('v4-script.min.js'))
  68. .pipe(gulp.dest('./js/', { overwrite:true })),
  69. console.log("JS built 🔧 "),
  70. cb();
  71. }
  72. function jsf(cb) {
  73. return streamqueue({ objectMode: true },
  74. gulp.src('./js/v4-jquery.js'),
  75. gulp.src('./js/svg-morpheus.js'),
  76. gulp.src('./js/messenger.min.js'),
  77. gulp.src('./js/v4-bootstrap.js'),
  78. gulp.src('./js/terminal.js'),
  79. gulp.src('./js/front-page.js')
  80. )
  81. .pipe(concat('v4-front.js'))
  82. .pipe(terser({ output: {comments: false} }))
  83. .pipe(rename('v4-front.min.js'))
  84. .pipe(gulp.dest('./js/', { overwrite:true })),
  85. console.log("JSF built 🔧 "),
  86. cb();
  87. }
  88. function mixin(cb) {
  89. return gulp.src('./css/**/*.scss')
  90. .pipe(sass().on('error',sass.logError))
  91. .pipe(gulp.dest('./css/'))
  92. .pipe(browserSync.stream()),
  93. console.log("Mixin 🎨"),
  94. cb();
  95. }
  96. function reload(cb) {
  97. browserSync.reload();
  98. cb();
  99. }
  100. function run() {
  101. browserSync.init({
  102. open: 'external',
  103. host: 'daw.ovid',
  104. proxy: 'https://daw.ovid',
  105. port: '333',
  106. ssl: {
  107. key: '/opt/homebrew/etc/httpd/ssl/daw.ovid-key.pem',
  108. cert: '/opt/homebrew/etc/httpd/ssl/daw.ovid.pem'
  109. }
  110. });
  111. gulp.watch(['./style.css', './css/*.scss',]).on('change', gulp.series(mixin, build));
  112. gulp.watch(['./**/*.php', './**/*.js', './**/*.css']).on('change', gulp.series(reload));
  113. console.log("🔥 Run");
  114. }
  115. exports.copy = copy;
  116. exports.build = build;
  117. exports.cssf = cssf;
  118. exports.js = js;
  119. exports.jsf = jsf;
  120. exports.mixin = mixin;
  121. exports.run = run;