You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 13, 2018. It is now read-only.
For example, say I want to add an inline plugin to BrowserSync for some quick and dirty hacking - using a URL logger as an example, it would be cool if it was possible to create a toggle for each plugin, regardless of whether the plugin has UI code/markup.
varPLUGIN_NAME="Asset Logger";varlogger={// Name of Plugin"plugin:name": PLUGIN_NAME,// Interface for BrowserSyncplugin: function(opts,bs){// Middleware are given a name to be easily accessed/removedvarmwname="asset-logger";// Add the middleware at run time.addMiddleware();// Listen to plugins:configure event and add/remove middleware accordinglybs.events.on("plugins:configure",function(data){// Don't act on any other pluginsif(data.name!==PLUGIN_NAME){return;}// If toggle switch = onif(data.active){if(!bs.app.stack.some(function(item){returnitem.id===mwname;})){addMiddleware();}}else{// If toggle switch = offbs.removeMiddleware(mwname);}});functionaddMiddleware(){bs.addMiddleware("*",function(req,res,next){// our pseudo middlewareconsole.log(req.url);next();},{override: true,id: mwname});}}};bs=require("browser-sync");bs.init({server: "./app",plugins: [logger]});
The text was updated successfully, but these errors were encountered:
For example, say I want to add an inline plugin to BrowserSync for some quick and dirty hacking - using a URL logger as an example, it would be cool if it was possible to create a toggle for each plugin, regardless of whether the plugin has UI code/markup.
The text was updated successfully, but these errors were encountered: