Skip to content

Commit

Permalink
Adds required backslash changes for windows compatibility (#11606)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkemper-pca authored Nov 8, 2024
1 parent 9dc2cb4 commit ceaa937
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Path = require('path');
const fs = require('fs');

function buildFilepathLookup(path, staticUrlPrefix) {
path = path.replace(/\\/g, '/')
if (!fs.existsSync(path)) {
return;
}
Expand All @@ -13,7 +14,7 @@ function buildFilepathLookup(path, staticUrlPrefix) {

const getFileList = function (dirPath) {
return fs.readdirSync(dirPath, { withFileTypes: true }).reduce((fileList,entries) => {
const childPath = Path.join(dirPath, entries.name);
const childPath = Path.join(dirPath, entries.name).replace(/\\/g, '/');

if (entries.isDirectory()) {
fileList.push(...getFileList(childPath, fileList));
Expand All @@ -37,7 +38,7 @@ function buildFilepathLookup(path, staticUrlPrefix) {
lookup[file.replace(path,'').replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = {"import": file, "filename": `${prefix}/[name].${extension}`};
}
else if (extension === 'css' || extension === 'scss') {
lookup[Path.join('css', file.replace(path,'').replace(/\\/g, '/')).replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
lookup[Path.join('css', file.replace(path,'')).replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
}
else {
// staticUrl used for images
Expand Down
5 changes: 3 additions & 2 deletions webpack/webpack-utils/build-filepath-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Path = require('path');
const fs = require('fs');

function buildFilepathLookup(path, staticUrlPrefix) {
path = path.replace(/\\/g, '/')
if (!fs.existsSync(path)) {
return;
}
Expand All @@ -13,7 +14,7 @@ function buildFilepathLookup(path, staticUrlPrefix) {

const getFileList = function (dirPath) {
return fs.readdirSync(dirPath, { withFileTypes: true }).reduce((fileList,entries) => {
const childPath = Path.join(dirPath, entries.name);
const childPath = Path.join(dirPath, entries.name).replace(/\\/g, '/');

if (entries.isDirectory()) {
fileList.push(...getFileList(childPath, fileList));
Expand All @@ -37,7 +38,7 @@ function buildFilepathLookup(path, staticUrlPrefix) {
lookup[file.replace(path,'').replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = {"import": file, "filename": `${prefix}/[name].${extension}`};
}
else if (extension === 'css' || extension === 'scss') {
lookup[Path.join('css', file.replace(path,'').replace(/\\/g, '/')).replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
lookup[Path.join('css', file.replace(path,'')).replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
}
else {
// staticUrl used for images
Expand Down

0 comments on commit ceaa937

Please sign in to comment.