vue-hot-reload-api
Note: vue-hot-reload-api@2.x
only works with vue@2.x
Hot reload API for Vue components. This is what vue-loader and vueify use under the hood.
Usage
You will only be using this if you are writing some build toolchain based on Vue components. For normal application usage, just use vue-loader
or vueify
.
const myComponentOptions = {
data () { ... },
created () { ... },
render () { ... }
}
if (module.hot) {
const api = require('vue-hot-reload-api')
const Vue = require('vue')
api.install(Vue)
if (!api.compatible) {
throw new Error('vue-hot-reload-api is not compatible with the version of Vue you are using.')
}
module.hot.accept()
if (!module.hot.data) {
api.createRecord('very-unique-id', myComponentOptions)
} else {
api.rerender('very-unique-id', myComponentOptions)
api.reload('very-unique-id', myComponentOptions)
}
}
License
MIT