nguyenbatranvan / vite-multiple-assets

npm package
https://www.npmjs.com/package/vite-multiple-assets
8 stars 7 forks source link

Plugin not Working do to difference in "\" and "/" #2

Closed Kingju777 closed 11 months ago

Kingju777 commented 11 months ago

Environment: Windows 10; Vite 4.4.7

Issue: fileObject can contain a path that is only different to file in the separator that is used.

example: fileObject[i].files[n] = "C:\Path\to\Folder/Foo.js" file = "C:\Path\to\Folder\Foo.js" => only the last separator before Foo.js is different

my proposed solution: instead of fileObject[i].files.includes(file) fileObject[i].files.some(f => path.relative(f, file) === "")

nguyenbatranvan commented 11 months ago

Environment: Windows 10; Vite 4.4.7

Issue: fileObject can contain a path that is only different to file in the separator that is used.

example: fileObject[i].files[n] = "C:\Path\to\Folder/Foo.js" file = "C:\Path\to\Folder\Foo.js" => only the last separator before Foo.js is different

my proposed solution: instead of fileObject[i].files.includes(file) fileObject[i].files.some(f => path.relative(f, file) === "")

Thank you for commenting on this bug for me!! As far as I see, this problem only occurs on window. This is the difference between the operating system's file association. Instead of the solution you suggested, we can check the current operating system and will decide whether to choose "/" or "\"

nguyenbatranvan commented 11 months ago

issue fixed version 1.2.1