You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an HTML file refers to an asset in a parent directory via a relative reference (../image.png), and the --public-url option is set to ./, the bundled version of the HTML tries to find it at image.png, instead of ../image.png. This works fine when the asset lives alongside the HTML, but in the case of HTML in a subfolder it does not.
I am writing an Electron app which loads a few images at run time from Javascript (in particular to present as an overlay on the taskbar icon). These images are used elsewhere and are bundled successfully by Parcel.
If the public URL was set as /, the generated references would be absolute rather than relative, and would work when hosted by a webserver.
However, being a desktop app, I cannot just refer to the files by their absolute path, relative to the root, as I might if hosted on a webserver.
(Actually, I think there's a better way of doing what I want, I need to research packing my files into an ASAR etc etc, but I'm reporting this as I think this is still a bug nonetheless)
💻 Code Sample
I've created a minimal sample and uploaded to GitHub. npm install, then npm start should have Parcel recreate the dist folder - you'll see the image doesn't work on dist/subfolder/subindex.html
🌍 Your Environment
Software
Version(s)
Parcel
1.8.0
Node
8.9.4
npm
5.8.0
Operating System
Windows 10
The text was updated successfully, but these errors were encountered:
🐛 Relative paths to parent directories don't work
When an HTML file refers to an asset in a parent directory via a relative reference (
../image.png
), and the--public-url
option is set to./
, the bundled version of the HTML tries to find it atimage.png
, instead of../image.png
. This works fine when the asset lives alongside the HTML, but in the case of HTML in a subfolder it does not.🎛 Configuration (.babelrc, package.json, cli command)
N/A
🤔 Expected Behavior
page.html:
😯 Current Behavior
page.html:
💁 Possible Solution
🔦 Context
I am writing an Electron app which loads a few images at run time from Javascript (in particular to present as an overlay on the taskbar icon). These images are used elsewhere and are bundled successfully by Parcel.
If the public URL was set as
/
, the generated references would be absolute rather than relative, and would work when hosted by a webserver.However, being a desktop app, I cannot just refer to the files by their absolute path, relative to the root, as I might if hosted on a webserver.
(Actually, I think there's a better way of doing what I want, I need to research packing my files into an ASAR etc etc, but I'm reporting this as I think this is still a bug nonetheless)
💻 Code Sample
I've created a minimal sample and uploaded to GitHub.
npm install
, thennpm start
should have Parcel recreate thedist
folder - you'll see the image doesn't work ondist/subfolder/subindex.html
🌍 Your Environment
The text was updated successfully, but these errors were encountered: