Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.