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.

Static asset in-lining

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

9reactions
jkschneidercommented, Jul 18, 2017

While debate continues on this, you can use raw-loader today without ejecting or forking with:

/* eslint import/no-webpack-loader-syntax: off */
import QuickStart from '!raw-loader!./Sections/QuickStart.md';

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.

1reaction
johnfluxcommented, Apr 25, 2018

Note that the !raw-loader! approach breaks the jest tests.

Read more comments on GitHub >

github_iconTop 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 >

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