-
-
Save MadeMyDay/476a3285475dffc18f66facb83b4cbfc to your computer and use it in GitHub Desktop.
simple gulpfile with stylus, browser sync,
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
// 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