Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
rollup-plugin-url
Advanced tools
This module has moved and is now available at @rollup/plugin-url. Please update your dependencies. This repository is no longer maintained.
Inline import files as data-URIs, or copy them to output
npm i --save-dev rollup-plugin-url
import {rollup} from "rollup"
import url from "rollup-plugin-url"
const writeoptions = {dest: "output/output.js"}
const plugin = url({
limit: 10 * 1024, // inline files < 10k, copy files > 10k
include: ["**/*.svg"], // defaults to .svg, .png, .jpg and .gif files
emitFiles: true // defaults to true
})
rollup({
entry: "main.js",
plugins: [plugin],
})
.then(bundle => bundle.write(writeoptions))
Optional. Type: number
.
This is the file size limit to inline files. If files exceed this limit, they
will be copied instead to the destination folder and the hashed filename will
be given instead. If value set to 0
all files will be copied.
Defaults to 14336 (14kb).
Optional. Type: a minimatch pattern, or array of minimatch patterns
These patterns determine which files are inlined. Defaults to .svg, .png, .jpg and .gif files.
Optional. Type: string
The publicPath
will be added in front of file names when they are not inlined
but copied.
Optional. Type: boolean
The emitFiles
option is used to run the plugin as you normally would but prevents any files being emitted. This is useful for when you are using rollup to emit both a client side and server side bundle.
Optional. Type: string
When emitFiles
is true
, the fileName
option can be used to rename the emitted files. It accepts the following string replacements:
[hash]
- The hash value of the file's contents[name]
- The name of the imported file, without it's file extension[extname]
- The extension of the imported file, including the leading .
[dirname]
- The parent directory name of the imported file, including trailing /
Defaults to: "[hash][extname]"
Optional. Type: string
When using the [dirname]
replacement in fileName
, uses this directory as the source directory to create the file path from rather than the parent directory of the imported file. For example:
src/path/to/file.js
import png from "./image.png";
rollup.config.js
url({
fileName: "[dirname][hash][extname]",
sourceDir: path.join(__dirname, "src")
})
Emitted File: path/to/image.png
Optional. Type: string
The destination dir to copy assets, usually used to rebase the assets according to HTML files.
FAQs
Inline import files as data-URIs, or copy them to output
The npm package rollup-plugin-url receives a total of 12,950 weekly downloads. As such, rollup-plugin-url popularity was classified as popular.
We found that rollup-plugin-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.