Gulpfile.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. var gulp = require("gulp");
  2. var sass = require("gulp-sass");
  3. var autoprefixer = require("gulp-autoprefixer");
  4. var cleancss = require("gulp-clean-css");
  5. var rename = require("gulp-rename");
  6. var input = "scss/*.scss";
  7. var output = "public/css";
  8. var sassOptions = {
  9. "errLogToConsole": true,
  10. "outputStyle": "expanded"
  11. };
  12. var autoprefixerOptions = {
  13. "browsers": ["last 2 versions", "ie >= 9", "and_chr >= 2.3"]
  14. };
  15. var vendorCssFiles = [
  16. "./node_modules/datatables.net-bs4/css/dataTables.bootstrap4.min.css",
  17. "./node_modules/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css",
  18. "./node_modules/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css",
  19. "./node_modules/daterangepicker/daterangepicker.css",
  20. ];
  21. var jsFiles = [
  22. "./node_modules/jquery/dist/jquery.min.*",
  23. "./node_modules/bootstrap/dist/js/bootstrap.min.*",
  24. "./node_modules/popper.js/dist/umd/popper.min.*",
  25. "./node_modules/chart.js/dist/Chart.bundle.min.js",
  26. "./node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.min.js",
  27. "./node_modules/clipboard/dist/clipboard.min.js",
  28. "./node_modules/@fortawesome/fontawesome-pro/js/all.min.js",
  29. "./node_modules/@google/markerclusterer/src/markerclusterer.js",
  30. "./node_modules/datatables.net/js/jquery.dataTables.min.js",
  31. "./node_modules/datatables.net-buttons/js/dataTables.buttons.min.js",
  32. "./node_modules/datatables.net-responsive/js/dataTables.responsive.min.js",
  33. "./node_modules/datatables.net-bs4/js/dataTables.bootstrap4.min.js",
  34. "./node_modules/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js",
  35. "./node_modules/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js",
  36. "./node_modules/moment/min/moment.min.js",
  37. "./node_modules/daterangepicker/daterangepicker.js",
  38. ];
  39. gulp.task("copy-vendor-css", function() {
  40. return gulp.src(vendorCssFiles).pipe(gulp.dest("./public/css"));
  41. });
  42. gulp.task("copy-js", function() {
  43. return gulp.src(jsFiles).pipe(gulp.dest("./public/js"));
  44. });
  45. gulp.task("sass", function() {
  46. return gulp
  47. .src(input)
  48. .pipe(sass(sassOptions).on("error", sass.logError))
  49. .pipe(autoprefixer(autoprefixerOptions))
  50. .pipe(cleancss())
  51. .pipe(rename({
  52. "suffix": ".min"
  53. }))
  54. .pipe(gulp.dest(output));
  55. });
  56. gulp.task("watch", function() {
  57. gulp.watch(jsFiles, gulp.series("copy-js"))
  58. .on("change", function(event) {
  59. console.log("File " + event.path + " was " + event.type + ", running 'copy-js' task...");
  60. });
  61. return gulp
  62. .watch(input, gulp.series("sass"))
  63. .on("change", function(event) {
  64. console.log("File " + event.path + " was " + event.type + ", running 'sass' task...");
  65. })
  66. });
  67. gulp.task("default", gulp.series("sass", "copy-vendor-css", "copy-js", "watch"));