SHARE
TWEET

Untitled

a guest Aug 25th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const gulp = require("gulp"),
  2.     browserify = require("browserify"),
  3.     babelify = require("babelify"),
  4.     buffer = require("vinyl-buffer"),
  5.     source = require("vinyl-source-stream"),
  6.     cssnano = require("cssnano"),
  7.     postcss = require("gulp-postcss"),
  8.     uglify = require("gulp-uglify"),
  9.     htmlmin = require("gulp-htmlmin"),
  10.     del = require("del");
  11.  
  12. const paths = {
  13.     source: "./src",
  14.     build: "./build"
  15. };
  16.  
  17. function cleanup() {
  18.     return del([paths.build]);
  19. }
  20.  
  21. function javascriptBuild() {
  22.     return browserify({
  23.         entries: [`${paths.source}/scripts/main.js`],
  24.         debug: true,
  25.         transform: [
  26.             babelify.configure({
  27.                 presets: ["@babel/preset-env"]
  28.             })
  29.         ]
  30.     })
  31.         .bundle()
  32.         .pipe(source("bundle.js"))
  33.         .pipe(buffer())
  34.         .pipe(uglify())
  35.         .pipe(gulp.dest(`${paths.build}/scripts/`));
  36. }
  37.  
  38. function htmlBuild() {
  39.     return gulp
  40.         .src(`${paths.source}/*.html`)
  41.         .pipe(htmlmin({ collapseWhitespace: true }))
  42.         .pipe(gulp.dest(paths.build));
  43. }
  44.  
  45. function cssBuild() {
  46.     return gulp
  47.         .src(`${paths.source}/styles/**/*.css`)
  48.         .pipe(postcss([cssnano()]))
  49.         .pipe(gulp.dest(`${paths.build}/styles`));
  50. }
  51.  
  52. exports.default = exports.build = gulp.series(cleanup, gulp.parallel(javascriptBuild, htmlBuild, cssBuild));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top