1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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.
This commit is contained in:
Arunoda Susiripala 2017-05-09 23:09:48 -07:00 committed by Tim Neutkens
parent c545a89fdf
commit 2f4a662a48

View file

@ -12,7 +12,17 @@ export default class PagesPlugin {
pages.forEach((chunk) => { pages.forEach((chunk) => {
const page = compilation.assets[chunk.name] const page = compilation.assets[chunk.name]
const pageName = matchRouteName.exec(chunk.name)[1] 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 content = page.source()
const newContent = ` const newContent = `