Skip to content

Instantly share code, notes, and snippets.

@jasonyingling
Created February 1, 2019 04:26
Show Gist options
  • Save jasonyingling/d6fcd7352c47b102f895642e4b31efb7 to your computer and use it in GitHub Desktop.
Save jasonyingling/d6fcd7352c47b102f895642e4b31efb7 to your computer and use it in GitHub Desktop.
A simple gulpfile setup for modern JavaScript and SASS
const { src, dest, watch } = require('gulp');
const sass = require('gulp-sass');
const minifyCSS = require('gulp-csso');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const browserSync = require('browser-sync').create();
function css() {
return src('./sass/*.scss', { sourcemaps: true })
.pipe(sass())
.pipe(minifyCSS())
.pipe(dest('./'), { sourcemaps: true })
.pipe(browserSync.stream());
}
function js() {
return src('./js/*.js', { sourcemaps: true })
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(concat('build.min.js'))
.pipe(dest('./js/min', { sourcemaps: true }));
}
function browser() {
browserSync.init({
proxy: 'domain.local',
files: [
'./**/*.php'
]
});
watch('./sass/**/*.scss', css);
watch('./js/*.js', js).on('change', browserSync.reload);
}
exports.css = css;
exports.js = js;
exports.default = browser;
@eliasfaical
Copy link

Good job, i liked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment