From 2f4a662a48d5b0ec5389b42f74a91653dd9e0fe8 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Tue, 9 May 2017 23:09:48 -0700 Subject: [PATCH] Fix windows sub-path dev rebuild failed issue. (#1930) * Fix windows sub-path dev rebuild failed issue. * Make sure we apply the '\' replace only on windows. --- server/build/plugins/pages-plugin.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/build/plugins/pages-plugin.js b/server/build/plugins/pages-plugin.js index 203fbe60..b8a827f9 100644 --- a/server/build/plugins/pages-plugin.js +++ b/server/build/plugins/pages-plugin.js @@ -12,7 +12,17 @@ export default class PagesPlugin { pages.forEach((chunk) => { const page = compilation.assets[chunk.name] const pageName = matchRouteName.exec(chunk.name)[1] - const routeName = `/${pageName.replace(/[/\\]?index$/, '')}` + let routeName = `/${pageName.replace(/[/\\]?index$/, '')}` + + // We need to convert \ into / when we are in windows + // to get the proper route name + // Here we need to do windows check because it's possible + // to have "\" in the filename in unix. + // Anyway if someone did that, he'll be having issues here. + // But that's something we cannot avoid. + if (/^win/.test(process.platform)) { + routeName = routeName.replace(/\\/g, '/') + } const content = page.source() const newContent = `