Skip to content

Commit

Permalink
Attempt #2 for fix paths
Browse files Browse the repository at this point in the history
  • Loading branch information
bendvc committed Jan 14, 2025
1 parent ae8b943 commit c982ab8
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,23 @@ const OverrideResolverLoader = function (this: LoaderContext<any>) {
const newBasedir = path.dirname(resolvedResourcePath)

// Provided a match and group representing a relative path, replace it with an absolute path using the new base directory.
// const convertRelativePaths = (match: string, relativePath: string) => {
// const absolutePath = path.resolve(newBasedir, relativePath)

// return match.replace(relativePath, absolutePath)
// }
const os = require('os')

const convertRelativePaths = (match: string, relativePath: string) => {
const absolutePath = path.posix.resolve(newBasedir, relativePath)
// Resolve the absolute path
let absolutePath = path.resolve(newBasedir, relativePath);

// Check if the OS is Windows
if (os.platform() === 'win32') {
// Escape backslashes by replacing \ with \\
absolutePath = absolutePath.replace(/\\/g, '\\\\')
}

return match.replace(relativePath, absolutePath)
}

Expand Down

0 comments on commit c982ab8

Please sign in to comment.