diff --git a/lib/utils.js b/lib/utils.js index 36baaf1d..5bb0dea2 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,10 +1,8 @@ const os = require("os"); -const path = require("path"); const { getAppPathFromProjectData, getAppResourcesPathFromProjectData, - getProjectDir, isAndroid, } = require("../projectHelpers"); @@ -92,6 +90,10 @@ function removeListener(eventEmitter, name) { } } +function convertToUnixPath(relativePath) { + return relativePath.replace(/\\/g, "/"); +} + module.exports = { buildEnvData, debuggingEnabled, @@ -99,5 +101,6 @@ module.exports = { getUpdatedEmittedFiles, parseHotUpdateChunkName, addListener, - removeListener + removeListener, + convertToUnixPath }; diff --git a/markup-hot-loader.js b/markup-hot-loader.js index 6d0ffd0a..e811dd5d 100644 --- a/markup-hot-loader.js +++ b/markup-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeMarkup = "markup"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeMarkup, path: modulePath })}`; }; diff --git a/script-hot-loader.js b/script-hot-loader.js index be828359..b9d07416 100644 --- a/script-hot-loader.js +++ b/script-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeScript = "script"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeScript, path: modulePath })}`; }; diff --git a/style-hot-loader.js b/style-hot-loader.js index e581cfbd..c4c3822a 100644 --- a/style-hot-loader.js +++ b/style-hot-loader.js @@ -1,7 +1,9 @@ const { reload } = require("./hot-loader-helper"); +const { convertToUnixPath } = require("./lib/utils"); module.exports = function (source) { const typeStyle = "style"; - const modulePath = this.resourcePath.replace(this.rootContext, "."); + const moduleRelativePath = this.resourcePath.replace(this.rootContext, "."); + const modulePath = convertToUnixPath(moduleRelativePath); return `${source};${reload({ type: typeStyle, path: modulePath })}`; };