
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
url-loader
Advanced tools
A loader for webpack which transforms files into base64 URIs.
This module requires a minimum of Node v6.9.0 and Webpack v4.0.0.
To begin, you'll need to install url-loader:
$ npm install url-loader --save-dev
url-loader works like
file-loader, but can return
a DataURL if the file is smaller than a byte limit.
import img from './image.png'
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
}
]
}
}
And run webpack via your preferred method.
fallbackType: String
Default: 'file-loader'
Specifies an alternative loader to use when a target file's size exceeds the
limit set in the limit option.
// webpack.config.js
{
loader: 'url-loader',
options: {
fallback: 'responsive-loader'
}
}
The fallback loader will receive the same configuration options as url-loader.
For example, to set the quality option of a responsive-loader above use:
{
loader: 'url-loader',
options: {
fallback: 'responsive-loader',
quality: 85
}
}
limitType: Number
Default: undefined
A Number specifying the maximum size of a file in bytes. If the file is
greater than the limit,
file-loader is used by
default and all query parameters are passed to it. Using an alternative to
file-loader is enabled via the fallback option.
The limit can be specified via loader options and defaults to no limit.
// webpack.config.js
{
loader: 'url-loader',
options: {
limit: 8192
}
}
mimetypeType: String
Default: (file extension)
Sets the MIME type for the file to be transformed. If unspecified the file extensions will be used to lookup the MIME type.
// webpack.config.js
{
loader: 'url-loader',
options: {
mimetype: 'image/png'
}
}
Please take a moment to read our contributing guidelines if you haven't yet done so.
1.1.2 (2018-10-10)
webpack =< v3.0.0 (peerDependencies) (#150) (a6860fc)node version range (engines) (#155) (d37b108)options to the default fallback (file-loader) (#139) (401be63)<a name="1.1.1"></a>
file-loader resolves import/require() on a file into a url and emits the file into the output directory. It is similar to url-loader but does not convert files to Data URLs. It is often used as a fallback for url-loader when files exceed the specified limit.
raw-loader loads files as a string and is similar to url-loader in the sense that it allows the inclusion of file contents inline in the code. However, it does not encode the files to Base64, nor does it have a fallback mechanism like url-loader.
svg-url-loader is designed specifically for SVG files. It encodes SVGs into compact Data URLs, similar to what url-loader does for general files. It has optimizations for SVGs, such as removing unnecessary whitespace, newlines, and comments, which url-loader does not perform by default.
FAQs
A loader for webpack which transforms files into base64 URIs
The npm package url-loader receives a total of 3,880,074 weekly downloads. As such, url-loader popularity was classified as popular.
We found that url-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.