Skip to content

Instantly share code, notes, and snippets.

@chodorowicz
Last active November 22, 2017 10:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chodorowicz/cb7d7545de7ae7413def to your computer and use it in GitHub Desktop.
Save chodorowicz/cb7d7545de7ae7413def to your computer and use it in GitHub Desktop.
simple gulpfile with stylus, browser sync,
// this method is currently broken
// better use vinyl-source-stream method
// http://fettblog.eu/gulp-browserify-multiple-bundles/
const gulp = require('gulp');
const browserify = require('browserify');
const transform = require('vinyl-transform');
const browserSync = require('browser-sync');
const reload = browserSync.reload;
const gutil = require('gulp-util');
var paths = {
scripts: ["./js/**/*.js"],
stylusEntry: ["./gfx/stylus/new.styl"],
stylusAll: ["./gfx/**/*.styl"]
};
gulp.task('browserify', function () {
var browserified = transform(function(filename) {
var b = browserify(filename);
return b.bundle();
});
return gulp.src(['./js/*.js'])
.pipe(browserified)
.pipe(gulp.dest('./dist/js'))
.pipe(reload({stream:true}));
});
gulp.task("stylus", function() {
gulp.src(paths.stylusEntry)
.pipe(stylus())
.on('error', gutil.log)
.pipe(gulp.dest('./gfx'))
.pipe(reload({stream:true}));
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['browserify']);
gulp.watch("./dist/index.html", reload);
gulp.watch(paths.stylusAll, ['stylus']);
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./dist"
}
});
});
// browersync with server proxy
// gulp.task('browser-sync', function() {
// browserSync({
// proxy: "silknew.dev"
// });
// });
gulp.task("default", ["watch", "browser-sync"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment