Skip to content

Instantly share code, notes, and snippets.

@cevhyruz
Last active August 2, 2019 15:51
Show Gist options
  • Save cevhyruz/2a599c594c142398937977186aa0f86d to your computer and use it in GitHub Desktop.
Save cevhyruz/2a599c594c142398937977186aa0f86d to your computer and use it in GitHub Desktop.
my gulpfile for front-end task
(function ($window, $document, bs) {
var socket = bs.socket;
socket.on("disconnect", function (client) {
window.close();
window.log
});
})(window, document, ___browserSync___);
'use strict';
const gulp = require('gulp'),
sass = require('gulp-sass'),
pug = require('gulp-pug'),
browserSync = require('browser-sync').create(),
del = require('del');
const pugIndex = './src/*.pug',
pugDest = './dist/';
const sassIndex = './src/sass/app.scss',
sassPath = './src/sass/**/*',
sassDest = './dist/';
function serveFiles() {
browserSync.use({
plugin: function () { /* noop */},
hooks: {
'client:js': require("fs").readFileSync("./closer.js", "utf-8")
}
});
browserSync.init({
server: {
baseDir : './dist',
port : 3000
}
});
gulp.watch(sassPath, {
interval: 500
}, buildSass);
gulp.watch(pugIndex, {
interval: 500
}, buildPug).on('change', browserSync.reload);
}
function clean() {
return del('');
}
function buildPug() {
return gulp.src(pugIndex)
.pipe(pug({
doctype : 'html',
pretty : true
}))
.pipe(gulp.dest(pugDest));
}
function buildSass() {
return gulp.src(sassIndex)
.pipe(sass())
.pipe(gulp.dest(sassDest))
.pipe(browserSync.stream());
}
exports.default = serveFiles;
exports.pug = buildPug;
exports.sass = buildSass;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment