Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I get the URL of a file inside a service worker? #2939

Closed
quadrupleslap opened this issue Apr 20, 2019 · 3 comments
Closed

How can I get the URL of a file inside a service worker? #2939

quadrupleslap opened this issue Apr 20, 2019 · 3 comments
Labels
❔ Question Stale Inactive issues

Comments

@quadrupleslap
Copy link

quadrupleslap commented Apr 20, 2019

❔ Question

How can I get the URL of a file inside my service worker? I probably want something like url_for('./index.js').

Edit: I decided to use https://github.com/mugi-uno/parcel-plugin-bundle-manifest and it's working well so far. It'd be nice if someone could confirm that there isn't a much better approach.

🔦 Context

I'm trying to add offline support to my app.

💻 Code Sample

// service-worker.js

const CACHED = [
  '.',
  // These two don't work thanks to name mangling (and scss → css).
  './index.scss',
  './index.js'
];

...

🌍 Your Environment

Software Version(s)
Parcel 1.12.3
Node 11.14.0
npm/Yarn 6.9.0
Operating System Linux 5.0.7
@quadrupleslap quadrupleslap changed the title How can How can I get the URL of a file inside a service worker? Apr 20, 2019
@quasicomputational
Copy link

#2306 would be a generic solution so long as the set of assets you want to reference is known statically. I don't think there's a way to do this sort of thing today that doesn't involve a plugin.

@mischnic
Copy link
Member

mischnic commented May 4, 2019

There is currently no better way to achieve this. (Could personally see this being added using require.resolve(...) returning the output path)

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 18, 2020
@github-actions github-actions bot closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❔ Question Stale Inactive issues
Projects
None yet
Development

No branches or pull requests

4 participants