Created
July 2, 2018 14:22
-
-
Save iamhosseindhv/b5dab20b9fa76fdce62d7995f98279b6 to your computer and use it in GitHub Desktop.
Browser sync for Webpack Encore Symfony 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
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
The one-liner that will save you from 30 seconds of research:
Thx alot!