Comments (3)
Glad you solved it, thanks for reporting back. It'd be great to have this piece of information on Parcelβs docs, which are somewhat lacking: https://parceljs.org/recipes/web-extension/
I added some extra links to the documentation b311e54
from browser-extension-template.
A few pointers:
- You have to use getURL in the content script or else the URLs will be relative to the current website rather than the extension. This also explains why it works without it on an extension page
- it appears that getURL is "not supported" by parcel: parcel-bundler/parcel#5758 (comment)
- the getURL example with the hashed filename works because it's ignored by Parcel and you're providing the final URL to it, so it's natively supported by the browser
Have you tried this?
import logo from "./blah blah/logo.png"
<img src={browser.runtime.getURL(logo)}/>
The logo
variable will be set by Parcel to "/logo.abcd56.png"
and that's a valid string to pass to getURL, you just need to make sure it points to the right element in the distribution folder (e.g. if it's inside images/, then also include that: getURL("images/" + logo)
from browser-extension-template.
that did the trick! π
// manifest.json
"web_accessible_resources": ["on-install/index.html", "images/*"]
// OnBoarding.jsx
import logoSrc from "../../images/logo.png"
const logo = browser.runtime.getURL(logoSrc)
maybe add this to the documentation?
(want me to PR that?)
THanks again, you ROCK!
from browser-extension-template.
Related Issues (20)
- Include the zipped extension in each release HOT 1
- Change repository description to reflect webpack -> parcel change HOT 1
- change project description from webpack to parcel HOT 1
- Issue with using import in content scripts HOT 5
- Need to restart the extension to see changes HOT 9
- Unsafe construction of an any type value. HOT 5
- Linting errors after converting to TypeScript HOT 5
- Source maps don't work by default HOT 4
- Document how to convert the project to use TypeScript
- Meta: Firefox deployment failed HOT 2
- Firefox support discussion (MV2, MV3) HOT 15
- erroneous issue, please delete sorry HOT 1
- Chrome Web Store rejection for obfuscated code HOT 4
- Lint css error, fetch tags error, duplicated addon once published HOT 1
- "Template cleanup" workflow broken HOT 1
- Include "popup" in template HOT 1
- Icon greyed out and no functionality HOT 5
- Allow retriggering a store submission HOT 1
- Nested folders in /src HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browser-extension-template.