gulp-io
Version:
iio's front-end build tools.
66 lines (59 loc) • 2.32 kB
JavaScript
/*
# BrowserSync
BrowserSync can either open the browser externally (through your IP address)
or locally (using localhost). Once opened, it can either show the page
statically, or dynamically sync the changes on save. It will either inject the
new code using websockets, or reload the page, depending on what kind of file
is saved.
*/
module.exports = function(gulp, plugins) {
var gulp = require('gulp');
// DEPENDENCIES
var browser = require('browser-sync'),
open = require("open");
// CONFIGURATIONS
var config = gulp.config.browser;
// TASKS
// BROWSER DEFAULT
gulp.task('browser', config.dependencies, function() {
browser(config.options);
// If the browser is set to null, the page will be opened in the default browser.
// If you don't want the default browser, overwrite the browser setting in you local config.
open(config.options.proxy.target + ":" + config.options.port + config.options.startPath, config.options.browser);
});
// BROWSER -> OPEN
gulp.task('browser:static', config.dependencies, function() {
browser(plugins.lodash.merge(config.options, {
// open: true,
online: false,
codeSync: false
}));
open(config.options.proxy.target + ":" + config.options.port + config.options.startPath, config.options.browser);
});
// BROWSER -> OPEN EXTERNAL
gulp.task('browser:external:static', config.dependencies, function() {
browser(plugins.lodash.merge(config.options, {
open: "external",
online: true,
codeSync: false
}));
});
// BROWSER -> OPEN & SYNC
gulp.task('browser:sync', config.dependencies, function() {
browser(plugins.lodash.merge(config.options, {
// open: true,
online: false,
codeSync: true
}));
open(config.options.proxy.target + ":" + config.options.port + config.options.startPath, config.options.browser);
});
// BROWSER -> OPEN EXTERNAL & SYNC
gulp.task('browser:external:sync', config.dependencies, function() {
browser(plugins.lodash.merge(config.options, {
open: "external",
online: true,
codeSync: true
}));
});
return gulp;
};