I have a web project with a working Webpack4 config using webpack-dev-server
with HMR enabled and started this way via npm script:
cross-env NODE_ENV=development webpack-dev-server --inline --hot
All is OK, HMR works for my js and scss files. Now I'm wondering if it's possible to extend my Webpack config to have a full reload in the browser when I modify a view template file.
It seems for me that webpack-dev-server
can't do this on its own, so I think I need some other plugin. After googling a bit this is I've got:
- webpack-dev-server + browser-sync-webpack-plugin
- rewrite my config to webpack-serve as it seems it can do it
- chokidar + webpack-dev-middleware (API for reloading?)
So my question is what is the best way to get HMR + watch given paths and reload browser on file change (blade/twig/php/etc...) with Webpack 4(.17.2) ?
Relevant part of my current config:
devServer: {
index: '',
open: true,
hotOnly: true,
publicPath: '/build/',
host: 'mysite.test',
proxy: {
'**': {
target: 'http://mysite.test',
changeOrigin: true,
headers: {
'X-Dev-Server-Proxy': 'http://mysite.test'
}
}
}
}