Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-recipe-browsersync-server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-recipe-browsersync-server - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

79

configReader.js

@@ -6,24 +6,7 @@ var paths = {};

$.utils.checkMandatory(config, ['sources.devAssets']);
$.utils.checkMandatory(config, ['sources.assets']);
// configure middleware
var lazyHistoryApi = _.once(function lazyHistoryApi() {
return $.connectHistoryApiFallback;
});
config.browserSync = _.merge(config.browserSync || {}, {dev: {}, dist: {}});
var devMiddleware = [], distMiddleware = [];
if (config.browserSync.useHistoryApi || config.browserSync.dev.useHistoryApi) {
devMiddleware.push(lazyHistoryApi());
}
if (config.browserSync.useHistoryApi || config.browserSync.dist.useHistoryApi) {
distMiddleware.push(lazyHistoryApi());
}
// preconfigure defaults that may be used in further config
config = _.merge({
ports: {
dev: 3000,
dist: 3100
},
// extract shared browserSync config
var rawBS = _.merge(_.omit(config.browserSync || {}, ['dev', 'dist']), {server: {}});
config = $.lodash.merge({
paths: {

@@ -33,7 +16,9 @@ app: 'app/',

dist: 'dist/'
}
}, config);
config = $.lodash.merge({
tasks: {
},
browserSync: {
// apply shared as default
dev: _.cloneDeep(rawBS),
dist: _.cloneDeep(rawBS)
},
tasks: {
browserSyncServe: 'serve',

@@ -44,16 +29,2 @@ browserSyncServeDist: 'serve:dist',

browserSyncCleanTemp: 'clean:temp'
},
browserSync: {
dev: {
port: config.ports.dev,
server: {
middleware: devMiddleware
}
},
dist: {
port: config.ports.dist,
server: {
middleware: distMiddleware
}
}
}

@@ -70,20 +41,22 @@ }, {

var plainBS = _.omit(_.clone(config.browserSync), 'dev', 'dist');
config.browserSync.dev = _.merge(_.cloneDeep(plainBS), config.browserSync.dev);
config.browserSync.dist = _.merge(_.cloneDeep(plainBS), config.browserSync.dist);
// assign these arrays only when not set alternatively, to prevent merge
if(!config.browserSync.dev.server.baseDir) {
config.browserSync.dev.server.baseDir = [config.paths.tmp, config.paths.app];
}
config.browserSync.dev.server.baseDir = config.browserSync.dev.server.baseDir || [config.paths.tmp, config.paths.app];
config.browserSync.dist.server.baseDir = config.browserSync.dist.server.baseDir || [config.paths.dist];
if(!config.browserSync.dist.server.baseDir) {
config.browserSync.dist.server.baseDir = [config.paths.dist];
}
// add temp folder to watcher
var tempFiles = config.paths.tmp + '**';
// prepare only needed source globs, content and fs checking is not needed.
var watchGlobs = _.chain([config.sources.build, config.sources.assets, tempFiles])
.map($.utils.parseSources)
.flatten()
.filter(function (s) { return s.watch !== false; })
.pluck('files')
.value();
if(!config.browserSync.dist.files) {
config.browserSync.dist.files = [config.paths.dist];
}
config.browserSync.dev.files = _.union(_.filter([config.browserSync.dev.files]), watchGlobs);
config.browserSync.dist.files = _.union(_.filter([config.browserSync.dist.files]), [config.paths.dist]);
// remove original sources, so no unnecessary load is performed
config.sources = undefined;
return config;
};
{
"name": "gulp-recipe-browsersync-server",
"version": "0.1.2",
"version": "0.1.3",
"description": "Receipe for serving files with autoreload",

@@ -5,0 +5,0 @@ "main": "main.js",

'use strict';
module.exports = function ($, config, sources) {
module.exports = function ($, config) {
var _ = $.lodash;

@@ -16,7 +16,3 @@

function browserSyncServeTask() {
var devAssetPipe = $.utils.mergedLazypipe($.utils.getPipes('devAsset'));
$.browserSync(_.merge(config.browserSync.dev, {
files: _.union(sources.devAssets.globs, devAssetPipe.globs, sources.index.globs)
}));
$.browserSync(config.browserSync.dev);
}

@@ -33,3 +29,2 @@

function browserSyncServeDistTask() {
console.log(config.browserSync.dist);
$.browserSync(config.browserSync.dist);

@@ -36,0 +31,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc