How to use path prefix with sirv?
See original GitHub issueThanks for great work. I am trying to use sirv with Polka and Sapper.
I have my public assets in folder ‘public’ and I want to reference those assets with path prefix say public/images/hero.jpg
.
When I use Sirv as app.use(sirv('public'))
, I need to refer static assets as images/hero.jpg
.
I am basically looking for something like app.use('/static', express.static(path.join(__dirname, 'public')))
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Getting started – Sirv REST API Documentation - Reference ...
Use this API method to search for files based on one or more criteria: file name; folder path; file extension; content type; created/modified...
Read more >Adding a Path Prefix - Gatsby
Add the path prefix to paths using withPrefix ... For pathnames you construct manually, there's a helper function, withPrefix that prepends your path...
Read more >sirv-auto-push - npm Package Health Analysis - Snyk
It is resolved to an absolute path — you must provide an absolute path yourself if process.cwd() is not the correct assumption. opts.prefix....
Read more >Shared Options - Vite
When aliasing to file system paths, always use absolute paths. Relative alias values will be ... Both Yarn and pnpm support aliasing via...
Read more >Svelte Single-Page Applications with Svelte Router SPA
Using this router and Svelte, we will be building the following ... option to sirv tells it to treat the public directory as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey, thanks~!
The current combination of Polka & Sapper doesn’t really allow for this right now, unless you do this:
A few others have had this request a few times, so I’ve opened a PR (https://github.com/sveltejs/sapper/pull/326) on Sapper to make this easier for Polka users. Hopefully it aligns with their goals, otherwise the above will do the trick for you 😃
Without Sapper, using
sirv
with Polka operates as you’d expect:GREAT SUCCESS! 💯
You are awesome. I can’t thank you enough. More than the solution I am grateful for goodwill. This has been very inspiring.