This commit is contained in:
Kent C. Dodds 2016-07-19 21:42:01 -06:00
parent 2943e0d4f7
commit e554eb0abe
2 changed files with 25 additions and 3 deletions

View File

@ -34,7 +34,7 @@
"prebuild:dev": "rimraf dist",
"build:dev": "webpack --env.dev",
"start": "http-server",
"dev": "webpack-dev-server --env.dev",
"dev": "webpack-dev-server --env.dev --hot",
"debug": "node-nightly --inspect --debug-brk node_modules/.bin/webpack --env.debug",
"debug:dev": "npm run debug -- --env.dev",
"debug:prod": "npm run debug -- --env.prod",

26
src/bootstrap.js vendored
View File

@ -1,5 +1,27 @@
/* eslint no-console:0 */
var app = require('./app')
var helpers = require('./helpers')
helpers.$on(window, 'load', app.onLoad)
helpers.$on(window, 'hashchange', app.onLoad)
// this is only relevant when using `hot` mode with webpack
// special thanks to Eric Clemmons: https://github.com/ericclemmons/webpack-hot-server-example
const reloading = document.readyState === 'complete'
if (module.hot) {
module.hot.accept(function(err) {
console.log('❌ HMR Error:', err)
})
if (reloading) {
console.log('🔁 HMR Reloading.')
app.onLoad()
} else {
console.info('✅ HMR Enabled.')
bootstrap()
}
} else {
console.info('❌ HMR Not Supported.')
bootstrap()
}
function bootstrap() {
helpers.$on(window, 'load', app.onLoad)
helpers.$on(window, 'hashchange', app.onLoad)
}