Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: use configure vueHotReloadAPI when available
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Oct 7, 2017
1 parent 5deae78 commit 19be9bf
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/template-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function compileTemplate (template, filename, config) {
errors: compiled.errors,
tips: compiled.tips
}
const vueHotReloadAPI = (config.require && config.require.vueHotReloadAPI) || 'vue-hot-reload-api'

if (output.errors && output.errors.length) {
output.code = config.esModule !== false
Expand Down Expand Up @@ -48,7 +49,7 @@ module.exports = function compileTemplate (template, filename, config) {
'\nif (module.hot) {\n' +
' module.hot.accept()\n' +
' if (module.hot.data) {\n' +
` require('vue-hot-reload-api').rerender('${options.scopeId}', module.exports)\n` +
` require(${JSON.stringify(vueHotReloadAPI)}).rerender(${JSON.stringify(options.scopeId)}, module.exports)\n` +
' }\n' +
'}'
}
Expand All @@ -62,7 +63,3 @@ function toFunction (code) {
indent_size: 2 // eslint-disable-line camelcase
}) + '}'
}

function pad (html) {
return html.split(/\r?\n/).map(line => ` ${line}`).join('\n')
}

0 comments on commit 19be9bf

Please sign in to comment.