Skip to content

Instantly share code, notes, and snippets.

@juanlcoto
Forked from jasonyingling/gulpfile.js
Created June 23, 2020 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanlcoto/3cee0dcf538696027e712866264061c2 to your computer and use it in GitHub Desktop.
Save juanlcoto/3cee0dcf538696027e712866264061c2 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment