Static asset in-lining
See original GitHub issueWhen 0.10 is released (with #1305), I have a feeling we’ll be seeing a lot more of issues like #1938.
These users have a perfectly legitimate use case and I believe we should handle it. They desire to require a text file, or other types (e.g. markdown, other markup), and receive raw data. There was also a recent issue asking to require JS as text and not processed as a module.
There are many imaginable use cases for this, and have been a huge amount of issues we’ve responded to with a
put it in a
export default '';
To remedy this, I believe we should in-line assets via fs.readFileSync(...)
, similar (identical) to brfs
.
This would allow users to require any arbitrary file as UTF8 text or a Buffer
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Avoiding The Pitfalls Of Automatically Inlined Code
With the objective of avoiding inlining, in this article we will explore how to convert inline code to static assets: Instead of printing ......
Read more >Static Asset Handling - Vite
Assets smaller in bytes than the assetsInlineLimit option will be inlined as base64 data URLs. Git LFS placeholders are automatically excluded from inlining...
Read more >Inline Static Assets in Builds · Issue #10619 · CesiumGS/cesium
The current CesiumJS distribution consists of a single, bundled JS entry point, Cesium.js, which inlines all library JS code.
Read more >static variables in an inlined function - c++ - Stack Overflow
Static means one copy is distributed throughout the program , but inline means it requires the same code for several time in ...
Read more >Inline All The Things - Jim Nielsen's Blog
Here's Chris' high-level summary of how he makes his sites fast: Serve pre-rendered, mostly static HTML. Inline everything, including CSS and ...
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
While debate continues on this, you can use raw-loader today without ejecting or forking with:
The leading
!
is important, as otherwise all but a defined set of excluded extensions will get loaded by file-loader instead.I know this isn’t recommended, but I find an explicit binding to Webpack to be more palatable than eject or forking. Feels like a tradeoff between trouble caused by some hypothetical future state where CRA no longer uses Webpack and trouble now maintaining my fork or falling behind on updates to key pieces of the setup.
Note that the !raw-loader! approach breaks the jest tests.