Skip to content

Commit

Permalink
fix: properly stringify hot-reload-api path for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 22, 2018
1 parent c672783 commit fb1306e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/codegen/hotReload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const hotReloadAPIPath = require.resolve('vue-hot-reload-api')
const hotReloadAPIPath = JSON.stringify(require.resolve('vue-hot-reload-api'))

exports.genHotReloadCode = (id, functional) => {
return wrap(`
Expand All @@ -13,7 +13,7 @@ exports.genHotReloadCode = (id, functional) => {
exports.genTemplateHotReloadCode = id => {
return wrap(`
if (module.hot.data) {
require('${hotReloadAPIPath}').rerender('${id}', {
require(${hotReloadAPIPath}).rerender('${id}', {
render: render,
staticRenderFns: staticRenderFns
})
Expand All @@ -25,7 +25,7 @@ function wrap (inner) {
return `
/* hot reload */
if (module.hot) {
var api = require('${hotReloadAPIPath}')
var api = require(${hotReloadAPIPath})
api.install(require('vue'))
if (api.compatible) {
module.hot.accept()
Expand Down
4 changes: 2 additions & 2 deletions lib/codegen/styleInjection.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { attrsToQuery } = require('./utils')
const hotReloadAPIPath = require.resolve('vue-hot-reload-api')
const hotReloadAPIPath = JSON.stringify(require.resolve('vue-hot-reload-api'))

module.exports = function genStyleInjectionCode (
loaderContext,
Expand Down Expand Up @@ -59,7 +59,7 @@ module.exports = function genStyleInjectionCode (
var newLocals = require(${request})
if (JSON.stringify(newLocals) !== JSON.stringify(oldLocals)) {
cssModules[${name}] = newLocals
require("${hotReloadAPIPath}").rerender("${id}")
require(${hotReloadAPIPath}).rerender("${id}")
}
}
})
Expand Down

0 comments on commit fb1306e

Please sign in to comment.