Created
August 13, 2019 19:35
-
-
Save BobbieGoede/a050bf20eb7633e43c8dfa525968fb28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gulp = require("gulp"), | |
browserify = require("browserify"), | |
babelify = require("babelify"), | |
buffer = require("vinyl-buffer"), | |
source = require("vinyl-source-stream"), | |
cssnano = require("cssnano"), | |
postcss = require("gulp-postcss"), | |
uglify = require("gulp-uglify"), | |
htmlmin = require("gulp-htmlmin"), | |
del = require("del"); | |
const paths = { | |
source: "./src", | |
build: "./build" | |
}; | |
function cleanup() { | |
return del([paths.build]); | |
} | |
function javascriptBuild() { | |
return browserify({ | |
entries: [`${paths.source}/scripts/main.js`], | |
debug: true, | |
transform: [ | |
babelify.configure({ | |
presets: ["@babel/preset-env"] | |
}) | |
] | |
}) | |
.bundle() | |
.pipe(source("bundle.js")) | |
.pipe(buffer()) | |
.pipe(uglify()) | |
.pipe(gulp.dest(`${paths.build}/scripts/`)); | |
} | |
function htmlBuild() { | |
return gulp | |
.src(`${paths.source}/*.html`) | |
.pipe(htmlmin({ collapseWhitespace: true })) | |
.pipe(gulp.dest(paths.build)); | |
} | |
function cssBuild() { | |
return gulp | |
.src(`${paths.source}/styles/**/*.css`) | |
.pipe(postcss([cssnano()])) | |
.pipe(gulp.dest(`${paths.build}/styles`)); | |
} | |
exports.default = exports.build = gulp.series(cleanup, gulp.parallel(javascriptBuild, htmlBuild, cssBuild)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment