diff --git a/lib/component-normalizer.js b/lib/component-normalizer.js index ab3b6a9d6..e6b13fc04 100644 --- a/lib/component-normalizer.js +++ b/lib/component-normalizer.js @@ -84,6 +84,9 @@ module.exports = function normalizeComponent ( ? [].concat(existing, hook) : [hook] } else { + // for template-only hot-reload because in that case the render fn doesn't + // go through the normalizer + options._injectStyles = hook // register for functioal component in vue file options.render = function renderWithStyleInjection (h, context) { hook.call(context) diff --git a/lib/loader.js b/lib/loader.js index 2cca97f06..a39155a47 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -386,17 +386,13 @@ module.exports = function (content) { output += '\n/* hot reload */\n' + 'if (module.hot) {(function () {\n' + - ' var hotAPI = require("' + - hotReloadAPIPath + - '")\n' + + ' var hotAPI = require("' + hotReloadAPIPath + '")\n' + ' hotAPI.install(require("vue"), false)\n' + ' if (!hotAPI.compatible) return\n' + ' module.hot.accept()\n' + ' if (!module.hot.data) {\n' + // initial insert - ' hotAPI.createRecord("' + - moduleId + - '", Component.options)\n' + + ' hotAPI.createRecord("' + moduleId + '", Component.options)\n' + ' } else {\n' // update if (cssModules) { @@ -406,7 +402,9 @@ module.exports = function (content) { ' }\n' } output += - ' hotAPI.reload("' + moduleId + '", Component.options)\n' + ' }\n' + ` hotAPI.${ + functionalTemplate ? 'rerender' : 'reload' + }("${moduleId}", Component.options)\n' + ' }\n` // dispose output += ' module.hot.dispose(function (data) {\n' + diff --git a/package.json b/package.json index c6eef3b7f..d398c124a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "prettier": "^1.7.0", "resolve": "^1.4.0", "source-map": "^0.6.1", - "vue-hot-reload-api": "^2.1.0", + "vue-hot-reload-api": "^2.2.0", "vue-style-loader": "^3.0.0", "vue-template-es2015-compiler": "^1.6.0" },