Skip to content

Commit 0802aaa

Browse files
committed
Convert slashes in public paths
1 parent cf0b281 commit 0802aaa

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎webpack.config.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ module.exports = {
6969
// CSS image usages end up in the `bundles/[hash]` output
7070
// directory, so we adjust the final path to navigate up
7171
// twice.
72-
return path.join("../..", getImgOutputPath(url, resourcePath));
72+
const outputPath = getImgOutputPath(url, resourcePath);
73+
return toPublicPath(path.join("../..", outputPath));
7374
},
7475
},
7576
},
@@ -198,3 +199,13 @@ function getImgOutputPath(url, resourcePath) {
198199
const outputDir = path.dirname(resourcePath).replace(prefix, "");
199200
return path.join(outputDir, path.basename(url));
200201
}
202+
203+
/**
204+
* Convert path to public path format, which always uses forward slashes, since it will
205+
* be placed directly into things like CSS files.
206+
*
207+
* @param {string} path Some path to a file.
208+
*/
209+
function toPublicPath(path) {
210+
return path.replace(/\\/g, '/');
211+
}

0 commit comments

Comments
 (0)