Last active
June 4, 2019 11:24
-
-
Save stsvilik/46bf34f76910fcf515ea00650134190f to your computer and use it in GitHub Desktop.
Gulp browserify, babelify, uglify and concat vendor files
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
/*! gulpfile.js */ | |
const gulp = require("gulp"); | |
const gutil = require("gulp-util"); | |
const browserify = require("browserify"); | |
const buffer = require("vinyl-buffer"); | |
const uglify = require("gulp-uglify"); | |
const sourcemaps = require("gulp-sourcemaps"); | |
const source = require("vinyl-source-stream"); | |
const concat = require("gulp-concat") | |
gulp.task("browserify", function() { | |
const b = browserify({ | |
entries: "./src/app.js", | |
debug: true, | |
}); | |
return b | |
.transform("babelify", {presets: ["es2015"]}) | |
.bundle() | |
.pipe(source("app.js")) | |
.pipe(buffer()) | |
.pipe(sourcemaps.init({loadMaps: true})) | |
.pipe(uglify()) | |
.on("error", gutil.log) | |
.pipe(sourcemaps.write("./")) | |
.pipe(gulp.dest("./dist/")); | |
}); | |
gulp.task("bundle", ["browserify"], function() { | |
return gulp.src([ | |
"vendor/jquery-3.1.0.min.js", | |
"dist/app.js" | |
]) | |
.pipe(buffer()) | |
.pipe(sourcemaps.init({loadMaps: true})) | |
.pipe(concat("app.js")) | |
.pipe(sourcemaps.write("./")) | |
.pipe(gulp.dest("dist")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since gulp upgraded to version 4 you can't no more write :
You must correct this by
Source : https://www.liquidlight.co.uk/blog/how-do-i-update-to-gulp-4/