I like using browser-sync for my js server because it has some features that I need except [HMR] "Hot Module Replacement". I mean it does replace the css files without reloading the page but when it comes to js files it reload my whole page unlike webpack-dev-server.
webpack-dev-server just replace the the file no matter whether it's css file or js but browser-sync just does the HMR for css.
Is there any special config or I need to write some code? how can I have it in browser-sync?
npm install --save-dev browser-sync browser-sync-webpack-plugin
const BrowserSyncPlugin = require("browser-sync-webpack-plugin")
module.exports = {
devServer: {
port: 3100
},
plugins: [
new BrowserSyncPlugin({
host: "localhost",
port: 3000,
// url for WebpackDevServer
proxy: "http://localhost:3100"
}, {
// prevent BrowserSync from reloading
// let WebpackDevServer handle it
reload: false
})
]
}
reference: https://www.npmjs.com/package/browser-sync-webpack-plugin
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.