Skip to content

Instantly share code, notes, and snippets.

@jasonyingling
Created February 1, 2019 04:26
Show Gist options
  • Select an option

  • Save jasonyingling/d6fcd7352c47b102f895642e4b31efb7 to your computer and use it in GitHub Desktop.

Select an option

Save jasonyingling/d6fcd7352c47b102f895642e4b31efb7 to your computer and use it in GitHub Desktop.

Revisions

  1. jasonyingling created this gist Feb 1, 2019.
    39 changes: 39 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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;