diff --git a/src/template-compiler/index.js b/src/template-compiler/index.js index a796e05..a694d5c 100644 --- a/src/template-compiler/index.js +++ b/src/template-compiler/index.js @@ -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 @@ -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' + '}' } @@ -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') -}