url-loader

A webpack loader that inlines small files as base64 Data URLs, falling back to file-loader for anything over a configurable size limit.

Tool
npm
v4.1.1
1,394 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
43 /100 Fair
Development Activity 0
Maintenance 20
Community 64
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
54 /100 Fair
Architecture 68
Code Quality 78
Innovation 30
Learning Curve 40

url-loader is a webpack loader that transforms imported files into base64-encoded Data URIs, embedding them directly inside the compiled JavaScript bundle instead of emitting them as separate files. It is most commonly used for small images, fonts, and icons where an extra HTTP request costs more than the inflated bundle size.

The loader accepts a limit option that caps how large a file can be before url-loader defers to a fallback loader — file-loader by default — so larger assets are still emitted as normal files with a resolved URL. Encoding, MIME type, and Data URI generation are all configurable, and a custom generator function lets projects swap in specialized encoders such as mini-svg-data-uri for more compact SVG output.

What You Get

  • Inline Data URI transformation for images, fonts, and other binary assets under a configurable size limit
  • Automatic fallback to file-loader (or any loader you specify) for files that exceed the limit
  • Configurable MIME type and encoding, including support for a custom generator function
  • esModule output toggle for compatibility with both ES module and CommonJS consumers

Common Use Cases

  • Inlining small UI icons and sprite images so pages avoid extra round-trips for tiny assets
  • Embedding web fonts as Data URIs to eliminate extra font-loading requests
  • Reducing HTTP/1.1 request overhead for legacy sites bundling many small images
  • Serving compact SVG Data URIs generated via a custom encoder like mini-svg-data-uri

Under The Hood

Architecture

url-loader is a single-purpose webpack loader function (src/index.js) exporting a default loader and a raw = true flag telling webpack to pass raw Buffer content. It validates options with schema-utils against options.json, decides via a small shouldTransform helper whether to inline or fall back, and when falling back, normalizes options through utils/normalizeFallback.js before dynamically requiring and invoking the fallback loader with a modified loader context. The design is flat and functional — a handful of small pure helpers (shouldTransform, getMimetype, getEncoding, getEncodedData) compose the encoding decision, with no class hierarchy or dependency-injection layer, appropriate for the narrow scope of a single webpack loader.

Tech Stack

Runtime dependencies are loader-utils (option parsing), mime-types (MIME resolution), and schema-utils (JSON-schema option validation) — all standard packages in the webpack-contrib ecosystem. The build pipeline uses Babel to transpile src/ to a published dist/, ESLint plus a shared webpack-contrib config and Prettier for linting/formatting, Jest for testing, and commitlint/husky/standard-version for conventional-commit-driven releases, with GitHub Actions running CI. The peer dependency is webpack ^4 or ^5, with file-loader as an optional peer for the default fallback path.

Code Quality

The test suite covers every documented option individually — loader, limit, encoding, mimetype, generator, fallback, esModule, and CJS-export behavior — using a shared getCompiler/compile/execute helper harness that runs the loader through an actual in-memory webpack build and snapshot-tests the resulting bundle output. ESLint and Prettier run in CI and via pre-commit hooks, and schema-utils enforces runtime option validation with descriptive errors. There is no TypeScript; the codebase is plain JavaScript with no static type layer.

What Makes It Unique

url-loader doesn’t introduce a new technique — inlining small assets as Data URIs versus emitting separate files is a long-standing bundler pattern, and the project itself is explicitly deprecated in favor of webpack 5’s built-in asset modules. Its distinguishing capabilities are the pluggable generator function, which lets consumers fully replace the Data URI encoding logic, and transparent fallback-loader delegation that preserves the original query so downstream loader options keep working unchanged.

Used by 18 apps in this directory

TypeScript
88%
Apache 2.0

Medplum

Authentication · Databases · Developer Tools

2,760

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
71
Dependency
Built with
TypeScript 88%
Updated 6 days ago
Go
52%
Apache 2.0

opencloud

File Storage

6,218

Open source file management and collaboration platform that keeps your data under your control, no database required.

View details
86
Repo Health
80
Technical
68
Dependency
Built with
Go 52%
Gherkin 33%
PHP 11%
Updated 1 weeks ago
TypeScript
96%
Apache 2.0

Pezzo

AI Development · Monitoring

3,278

Open-source LLMOps platform for prompt management, AI observability, intelligent caching, and real-time cost tracking across LLM providers.

View details
59
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 96%
Updated 2 months ago
TypeScript
97%
AGPL 3.0

Responsively App

Design Tools · Developer Tools

25,464

Preview and interact with your responsive web design across every device size simultaneously — no more manual resizing.

View details
79
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 3 weeks ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated 6 days ago
PHP
84%
MIT

wallabag

Bookmarks Archiving

13,023

Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.

View details
93
Repo Health
81
Technical
60
Dependency
Built with
PHP 84%
Twig 13%
Updated 1 weeks ago
TypeScript
87%
Other

Webiny JS

Blogging · CMS · Ecommerce

8,047

Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.

View details
90
Repo Health
86
Technical
61
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 1 weeks ago
TypeScript
41%
AGPL 3.0

Wiki.js

Collaboration · Knowledge Management

29,081

A modern, self-hosted wiki platform built on Node.js with a rich plugin ecosystem for authentication, search, storage, and rendering that adapts to any team's infrastructure.

View details
95
Repo Health
67
Technical
60
Dependency
Built with
TypeScript 41%
Vue 39%
JavaScript 16%
Updated 6 days ago
Python
57%
Apache 2.0

Zulip

Team Chat

26,102

Topic-based team chat that brings the structure of email threads to real-time messaging, so distributed teams never lose context across hundreds of concurrent conversations.

View details
96
Repo Health
86
Technical
60
Dependency
Built with
Python 57%
TypeScript 19%
JavaScript 11%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers