From 0802aaae914ac72ad9e19ac04ffb88098d595d1c Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Sat, 19 Jan 2019 00:29:25 +0100 Subject: [PATCH] Convert slashes in public paths --- webpack.config.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index e02c10504..e44d70ec0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -69,7 +69,8 @@ module.exports = { // CSS image usages end up in the `bundles/[hash]` output // directory, so we adjust the final path to navigate up // twice. - return path.join("../..", getImgOutputPath(url, resourcePath)); + const outputPath = getImgOutputPath(url, resourcePath); + return toPublicPath(path.join("../..", outputPath)); }, }, }, @@ -198,3 +199,13 @@ function getImgOutputPath(url, resourcePath) { const outputDir = path.dirname(resourcePath).replace(prefix, ""); return path.join(outputDir, path.basename(url)); } + +/** + * Convert path to public path format, which always uses forward slashes, since it will + * be placed directly into things like CSS files. + * + * @param {string} path Some path to a file. + */ +function toPublicPath(path) { + return path.replace(/\\/g, '/'); +}