Created
February 1, 2019 04:26
-
-
Save jasonyingling/d6fcd7352c47b102f895642e4b31efb7 to your computer and use it in GitHub Desktop.
A simple gulpfile setup for modern JavaScript and SASS
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
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
Good job, i liked