@@ -3,6 +3,7 @@ const { codeFrameColumns } = require(`@babel/code-frame`)
33const ansiHTML = require ( `ansi-html` )
44const fs = require ( `fs-extra` )
55const sysPath = require ( `path` )
6+ const { slash } = require ( `gatsby-core-utils` )
67
78const getPosition = function ( stackObject ) {
89 let filename
@@ -33,9 +34,9 @@ const getPosition = function (stackObject) {
3334 row = 0
3435 }
3536 return {
36- filename : filename ,
37- line : line ,
38- row : row ,
37+ filename,
38+ line,
39+ row,
3940 }
4041}
4142// Colors taken from Gatsby's design tokens
@@ -61,7 +62,7 @@ const parseError = function ({ err, directory, componentPath }) {
6162 directory ,
6263 // Don't need to use path.sep as webpack always uses a single forward slash
6364 // as a path separator.
64- ...position . filename . split ( `/` ) . slice ( 2 )
65+ ...position . filename . split ( sysPath . sep ) . slice ( 2 )
6566 )
6667
6768 const splitMessage = err . message ? err . message . split ( `\n` ) : [ `` ]
@@ -76,7 +77,7 @@ const parseError = function ({ err, directory, componentPath }) {
7677 ? componentPath
7778 : filename
7879 const data = {
79- filename : sysPath . relative ( directory , trueFileName ) ,
80+ filename : slash ( sysPath . relative ( directory , trueFileName ) ) ,
8081 message : message ,
8182 type : type ,
8283 stack : stack ,
@@ -153,7 +154,7 @@ exports.renderHTML = ({
153154 // Only generate error pages for webpack errors. If it's not a webpack
154155 // error, it's not a user error so probably a system error so we'll just
155156 // panic and quit.
156- const regex = / w e b p a c k : \/ l i b \/ / gm
157+ const regex = / w e b p a c k : [ / \\ ] / gm
157158 const moduleBuildFailed = / M o d u l e .b u i l d .f a i l e d / gm
158159 if ( stack . match ( moduleBuildFailed ) ) {
159160 reject ( `500 page` )
0 commit comments