7e7f2c0a6d
* Move client-side dev JS to dev folder * Move eventsource polyfill * Move source-map-support * Move error boundary * Deprecate Container in _app * Make initialRender check better * Remove unused code * Only support one subscription as there is only one * Don’t spread object * Shorten property name * Add container in development too * Simplify query update logic
35 lines
864 B
JavaScript
35 lines
864 B
JavaScript
import connect from './error-overlay/hot-dev-client'
|
|
|
|
export default ({ assetPrefix }) => {
|
|
const options = {
|
|
path: `${assetPrefix}/_next/webpack-hmr`
|
|
}
|
|
|
|
const devClient = connect(options)
|
|
|
|
devClient.subscribeToHmrEvent(obj => {
|
|
if (obj.action === 'reloadPage') {
|
|
return window.location.reload()
|
|
}
|
|
if (obj.action === 'removedPage') {
|
|
const [page] = obj.data
|
|
if (page === window.next.router.pathname) {
|
|
return window.location.reload()
|
|
}
|
|
return
|
|
}
|
|
if (obj.action === 'addedPage') {
|
|
const [page] = obj.data
|
|
if (
|
|
page === window.next.router.pathname &&
|
|
typeof window.next.router.components[page] === 'undefined'
|
|
) {
|
|
return window.location.reload()
|
|
}
|
|
return
|
|
}
|
|
throw new Error('Unexpected action ' + obj.action)
|
|
})
|
|
|
|
return devClient
|
|
}
|