A webpack plugin that starts and reloads Nodemon and Browsersync. It is useful when developing web applications that leverage both server-side rendered HTML pages and webpack bundles.
Initially based on Va1/browser-sync-webpack-plugin
Install the plugin with npm:
$ npm install nodemon-browsersync-webpack-plugin --save-dev
$ webpack --watch
Pass Nodemon options and BrowserSync options into the plugin in that order.
const NodemonBrowsersyncPlugin = require('nodemon-browsersync-webpack-plugin');
module.exports = {
entry: './src/js/entry.js',
output: {
path: './public/assets',
filename: 'bundle.js'
},
plugins: [
new NodemonBrowsersyncPlugin({
script: 'server.js',
ignore: [
"src/*",
"public/*"
],
ext: 'js json',
verbose: true
}, {
proxy: 'localhost:8001'
)
]
};
In the example above, Browsersync will wrap your vhost with a proxy URL to view your site.
NOTE: For reusabilty, a nodemon.json
configuration file is recommended rather than embedding Nodemon options in the plugin. Checkout the sample nodemon.json for further details.
Feel free to open issues to propose stuff and participate. Pull requests are also welcome.