question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parcel 2: Serving static data from the dev server

See original GitHub issue

🙋 Feature request

Currently, there’s no way easy way to add additional data into the dist dir provided by serve. I’ve previously advocated for this use case (#2461), where I have large binary files like 3D data that I do not want to push through the build process. The intermediate workaround has been to place a folder symlink into the dist/ directory, which works OK – I can filter out text/html responses on the client and pretend they are 404s.

Parcel 2 moves the dist dir into .parcel-cache, and seems to more aggressively wipe it. This means it’s very hard to get Parcel 2’s dev server to serve static data again. The code for serving static data is still there, however.

🤔 Expected Behavior

I would like a supported mechanism to serve static, unbuilt data from the Parcel dev server.

😯 Current Behavior

There is no way to serve static data, and the existing workarounds for Parcel 1 which were relied on by many is now effectively unusable.

💁 Possible Solution

Support extra configuration to the parcel dev server, either based on the code in #2461 or not.

🔦 Context

I believe I have provided a sufficient amount of context above.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:23
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
ghostcommented, Aug 28, 2019

Hello, So far I’ve been using parcel-plugin-static-files-copy to solve this, but ideally this should be built-in. Adding a +1 for this!

8reactions
ghostcommented, Dec 10, 2019

Hey, just also wanted to mention that these assets are:

  • very large
  • usually loaded anytime after build and depend on a user’s choice

So it definitely needs a directory that the app has access to when it’s running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Serve Static Files during Development with Parcel - Reddit
Suppose you are already deploying your website through Vercel with Parcel and need to serve a handful of static files.
Read more >
Parcel
Everything Parcel does is cached – transformation, dependency resolution, bundling, optimizing, and everything in between. This means the dev server restarts ...
Read more >
How to serve a json file with parcel without bundling it?
If you're using Parcel 2, you can do something like this: import jsonUrl from 'url:./data.json' // Fetch the file asynchronously from the ...
Read more >
Bundling and Building with Parcel - Beginner JavaScript
Parcel supports hot reloading and will automatically refresh the server whenever you make a change while developing. Once you are finished with developing,...
Read more >
Parcel.js: moving static resources to a separate folder - Medium
Apparently, this feature will be available in the next version, Parcel 2, which is still in development. I had a look at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found