Commit fb1306e6 authored by Evan You's avatar Evan You

fix: properly stringify hot-reload-api path for Windows

parent c6727838
const hotReloadAPIPath = require.resolve('vue-hot-reload-api') const hotReloadAPIPath = JSON.stringify(require.resolve('vue-hot-reload-api'))
exports.genHotReloadCode = (id, functional) => { exports.genHotReloadCode = (id, functional) => {
return wrap(` return wrap(`
...@@ -13,7 +13,7 @@ exports.genHotReloadCode = (id, functional) => { ...@@ -13,7 +13,7 @@ exports.genHotReloadCode = (id, functional) => {
exports.genTemplateHotReloadCode = id => { exports.genTemplateHotReloadCode = id => {
return wrap(` return wrap(`
if (module.hot.data) { if (module.hot.data) {
require('${hotReloadAPIPath}').rerender('${id}', { require(${hotReloadAPIPath}).rerender('${id}', {
render: render, render: render,
staticRenderFns: staticRenderFns staticRenderFns: staticRenderFns
}) })
...@@ -25,7 +25,7 @@ function wrap (inner) { ...@@ -25,7 +25,7 @@ function wrap (inner) {
return ` return `
/* hot reload */ /* hot reload */
if (module.hot) { if (module.hot) {
var api = require('${hotReloadAPIPath}') var api = require(${hotReloadAPIPath})
api.install(require('vue')) api.install(require('vue'))
if (api.compatible) { if (api.compatible) {
module.hot.accept() module.hot.accept()
......
const { attrsToQuery } = require('./utils') 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 ( module.exports = function genStyleInjectionCode (
loaderContext, loaderContext,
...@@ -59,7 +59,7 @@ module.exports = function genStyleInjectionCode ( ...@@ -59,7 +59,7 @@ module.exports = function genStyleInjectionCode (
var newLocals = require(${request}) var newLocals = require(${request})
if (JSON.stringify(newLocals) !== JSON.stringify(oldLocals)) { if (JSON.stringify(newLocals) !== JSON.stringify(oldLocals)) {
cssModules[${name}] = newLocals cssModules[${name}] = newLocals
require("${hotReloadAPIPath}").rerender("${id}") require(${hotReloadAPIPath}).rerender("${id}")
} }
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment