gulpfile.mjs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. import gulp from 'gulp';
  3. const { series, src, dest, watch } = gulp;
  4. import gulpif from 'gulp-if';
  5. import * as dartSass from 'sass';
  6. import gulpSass from 'gulp-sass';
  7. const sass = gulpSass(dartSass);
  8. import autoprefixer from 'gulp-autoprefixer';
  9. import stripDebug from 'gulp-strip-debug';
  10. import jsmin from 'gulp-jsmin';
  11. import cssmin from 'gulp-cssmin';
  12. import rename from 'gulp-rename';
  13. import minimist from 'minimist';
  14. import mainBowerFiles from 'main-bower-files';
  15. import svgmin from 'gulp-svgmin';
  16. // var shared_variables = JSON.parse(fs.readFileSync('./assets/json/shared_variables.json'));
  17. // to get minified assets run `gulp --env=prod`
  18. var argv = minimist(process.argv.slice(2));
  19. console.dir(argv);
  20. var prod = argv.env === 'prod' ? true : false;
  21. function handleError(err) {
  22. console.log(err.toString());
  23. }
  24. async function scripts() {
  25. return src(['./assets/scripts/main.js', './assets/scripts/redirect.js']) // './assets/scripts/shared_variables.js',
  26. // .pipe(concat('main.js'))
  27. .pipe(gulpif(prod, stripDebug()))
  28. .pipe(gulpif(prod, jsmin()))
  29. .pipe(rename({suffix: '.min'}))
  30. .pipe(dest('./assets/dist/scripts/'));
  31. }
  32. async function styles() {
  33. return src(['./assets/styles/app.scss'])
  34. .pipe(sass().on('error', sass.logError))
  35. .pipe(autoprefixer({
  36. cascade: false
  37. })).on('error', handleError)
  38. // .pipe(prod ? cssmin() : util.noop())
  39. .pipe(gulpif(prod, cssmin()))
  40. // .pipe(cssmin())
  41. .pipe(rename({suffix: '.min'}))
  42. .pipe(dest('./assets/dist/styles/'));
  43. }
  44. async function bower(){
  45. return src(mainBowerFiles({
  46. "overrides":{
  47. "masonry-layout":{
  48. "main":"./dist/masonry.pkgd.min.js"
  49. },
  50. "imagesloaded":{
  51. "main":"./imagesloaded.pkgd.min.js"
  52. },
  53. "jquery":{"ignore":true},
  54. "ev-emitter":{"ignore":true},
  55. "fizzy-ui-utils":{"ignore":true},
  56. "get-size":{"ignore":true},
  57. "outlayer":{"ignore":true},
  58. }
  59. }))
  60. .pipe(dest('./assets/dist/bower/'));
  61. }
  62. async function minsvg(){
  63. return src(['./assets/img/*.svg', '!./assets/img/edlp-loader-anim.svg'])
  64. .pipe(svgmin())
  65. .pipe(dest('./assets/dist/img'));
  66. }
  67. async function svg(){
  68. return src('./assets/img/edlp-loader-anim.svg')
  69. .pipe(dest('./assets/dist/img'));
  70. }
  71. function devwatch(){
  72. watch('./assets/styles/*.scss', styles);
  73. watch('./assets/styles/base/*.scss', styles);
  74. watch('./assets/scripts/*.js', scripts);
  75. watch('./assets/img/*.svg', svg);
  76. }
  77. export default series(scripts, styles, svg, minsvg);
  78. export { devwatch }