Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
browser-sync-webpack-plugin
Advanced tools
Easily use BrowserSync in your Webpack project.
$ npm install --save-dev browser-sync-webpack-plugin
or
$ yarn add --dev browser-sync-webpack-plugin
With release of 2.0.0 the plugin is expected to be used in Node v4+ environment. Support for Node v3 and lower was dropped, but you can install and use the plugin version of 1.2.0 in older environments.
BrowserSync will start only when you run Webpack in watch mode:
$ webpack --watch
If you're not using Webpack Dev Server, you can make BrowserSync to serve your project. The setup is pretty easy: just pass the BrowserSync options to the plugin as the first argument.
In your webpack.config.js
:
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
module.exports = {
// ...
plugins: [
new BrowserSyncPlugin({
// browse to http://localhost:3000/ during development,
// ./public directory is being served
host: 'localhost',
port: 3000,
server: { baseDir: ['public'] }
})
]
}
The advanced usage is about using Webpack Dev Server with BrowserSync in order to use awesome features of both.
To achieve this, BrowserSync offers the proxy option. So, basically, you are about to proxy the output from the Webpack Dev Server through BrowserSync to get the best out of both.
In your webpack.config.js
:
const BrowserSyncPlugin = require('browser-sync-webpack-plugin')
module.exports = {
// ...
plugins: [
new BrowserSyncPlugin(
// BrowserSync options
{
// browse to http://localhost:3000/ during development
host: 'localhost',
port: 3000,
// proxy the Webpack Dev Server endpoint
// (which should be serving on http://localhost:3100/)
// through BrowserSync
proxy: 'http://localhost:3100/'
},
// plugin options
{
// prevent BrowserSync from reloading the page
// and let Webpack Dev Server take care of this
reload: false
}
)
]
}
Other supported plugin options are:
name
- default: bs-webpack-plugin
, BrowserSync instance namecallback
- default: undefined
, BrowserSync instance init callback.injectCss
- default: false
, allows BrowserSync to inject changes inplace instead of reloading the page when changed chunks are all CSS filesFeel free to open issues to propose stuff and participate. Pull requests are also welcome.
FAQs
BrowserSync and Webpack integration
The npm package browser-sync-webpack-plugin receives a total of 101,527 weekly downloads. As such, browser-sync-webpack-plugin popularity was classified as popular.
We found that browser-sync-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.