Last active
February 26, 2024 07:02
-
-
Save kevinSuttle/c8b198aaa30349088c35 to your computer and use it in GitHub Desktop.
Gulp, BrowserSync, Sass, Autoprefixer, Nodemon
This file contains hidden or 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
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
var hbs = require('hbs'); | |
app.set('view engine', 'html'); | |
app.engine('html', hbs.__express); | |
app.use(express.json()); | |
app.use(express.urlencoded()); | |
app.use(express.static('public')); | |
app.get('/', function(req, res) { | |
res.sendfile('./views/index.html'); | |
}); | |
app.listen(5000); |
This file contains hidden or 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
var gulp = require('gulp'); | |
var sass = require('gulp-sass'); | |
var prefix = require('gulp-autoprefixer'); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
var nodemon = require('gulp-nodemon'); | |
gulp.task('sass', function () { | |
return gulp.src('public/scss/*.scss') | |
.pipe(sass({outputStyle: 'compressed', sourceComments: 'map'}, {errLogToConsole: true})) | |
.pipe(prefix("last 2 versions", "> 1%", "ie 8", "Android 2", "Firefox ESR")) | |
.pipe(gulp.dest('public/css')) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('browser-sync', ['nodemon'], function() { | |
browserSync.init(null, { | |
proxy: { | |
host: "http://localhost", | |
port: "5000" | |
} | |
}); | |
}); | |
gulp.task('default', ['sass', 'browser-sync'], function () { | |
gulp.watch("public/scss/*.scss", ['sass']); | |
gulp.watch(["public/js/**/*.js", "./*.html"], reload); | |
}); | |
gulp.task('nodemon', function (cb) { | |
var called = false; | |
return nodemon({script: 'app.js'}).on('start', function () { | |
if (!called) { | |
called = true; | |
cb(); | |
} | |
}); | |
}); |
This was a lifesaver, excellent work. Broswersync isn't 100% for me yet but it's definitely useable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@simonrobb +1 about the proxy accepting strings and not objects.