Last active
February 5, 2017 17:28
-
-
Save adamplabarge/f63a57bffa832c068d38337c9f238abb to your computer and use it in GitHub Desktop.
Babelify Browserify and SASS Gulp
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
Show hidden characters
{ | |
"presets": ["es2015"] | |
} |
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
'use strict'; | |
var gulp = require('gulp'); | |
var rename = require('gulp-rename'); | |
var sass = require('gulp-sass'); | |
var autopre = require('gulp-autoprefixer'); | |
var cleanCSS = require('gulp-clean-css'); | |
var mmq = require('gulp-merge-media-queries'); | |
var source = require('vinyl-source-stream'); | |
var uglify = require('gulp-uglify'); | |
var browserify = require('browserify'); | |
var babelify = require('babelify'); | |
var buffer = require('vinyl-buffer'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
// Watching scss/js files | |
gulp.task('watch', ['sass', 'javascript'], function () { | |
gulp.watch("./assets/scss/**/*.scss", ['sass']); | |
gulp.watch("./assets/js/**/*.js", ['javascript']); | |
}); | |
// Compile sass into CSS & auto-inject into browsers | |
gulp.task('sass', function () { | |
return gulp.src("./assets/scss/main.scss") | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(autopre({ | |
browsers: ['last 2 versions'], | |
cascade: false | |
})) | |
.pipe(mmq({ | |
log: true | |
})) | |
.pipe(cleanCSS({ compatibility: 'ie8' })) | |
.pipe(gulp.dest("./")) | |
}); | |
gulp.task('javascript', function () { | |
return browserify({entries: './assets/js/src/app.js', debug: true}) | |
.transform("babelify", { presets: ["es2015"] }) | |
.bundle() | |
.pipe(source('app.js')) | |
.pipe(buffer()) | |
.pipe(sourcemaps.init()) | |
.pipe(uglify()) | |
.pipe(sourcemaps.write('./js/maps/')) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('default', ['watch']); |
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
{ | |
"name": "", | |
"version": "1.0.0", | |
"dependencies": {}, | |
"devDependencies": { | |
"babel": "^6.5.2", | |
"babel-cli": "^6.18.0", | |
"babel-preset-es2015": "^6.18.0", | |
"babel-preset-es2016": "^6.16.0", | |
"babel-preset-es2017": "^6.16.0", | |
"babelify": "^7.3.0", | |
"browserify": "^13.3.0", | |
"del": "^1.1.1", | |
"gulp": "^3.9.1", | |
"gulp-autoprefixer": "3.1.1", | |
"gulp-browserify": "^0.5.1", | |
"gulp-cache": "~0.4.5", | |
"gulp-clean-css": "^2.0.13", | |
"gulp-merge-media-queries": "^0.2.1", | |
"gulp-rename": "^1.2.2", | |
"gulp-sass": "^2.3.2", | |
"gulp-sourcemaps": "^2.4.0", | |
"gulp-uglify": "^2.0.0", | |
"vinyl-buffer": "^1.0.0", | |
"vinyl-source-stream": "^1.1.0" | |
}, | |
"license": "", | |
"repository": { | |
"type": "", | |
"url": "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment