Skip to content

Instantly share code, notes, and snippets.

@iamhosseindhv
Created July 2, 2018 14:22
Show Gist options
  • Save iamhosseindhv/b5dab20b9fa76fdce62d7995f98279b6 to your computer and use it in GitHub Desktop.
Save iamhosseindhv/b5dab20b9fa76fdce62d7995f98279b6 to your computer and use it in GitHub Desktop.
Browser sync for Webpack Encore Symfony 4
let config = Encore.getWebpackConfig();
config.watchOptions = { poll: true, ignored: /node_modules/ };
config.plugins.push(
new BrowserSyncPlugin(
{
host: 'aro.tech',
proxy: 'aro.tech',
files: [ // watch on changes
{
match: ['public/build/**/*.js'],
fn: function (event, file) {
if (event === 'change') {
const bs = require('browser-sync').get('bs-webpack-plugin');
bs.reload();
}
}
}
]
},
{
reload: false, // this allow webpack server to take care of instead browser sync
name: 'bs-webpack-plugin',
},
)
);
module.exports = config;
@FlxSaenger
Copy link

The one-liner that will save you from 30 seconds of research:

npm i -D browser-sync browser-sync-webpack-plugin

Thx alot!

@7system7
Copy link

And a missing line:

const BrowserSyncPlugin = require('browser-sync-webpack-plugin');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment