Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tecc/rollup-plugin-import-data-uri
A simple plugin to import any file as a data URI.
https://github.com/tecc/rollup-plugin-import-data-uri
Last synced: about 2 months ago
JSON representation
A simple plugin to import any file as a data URI.
- Host: GitHub
- URL: https://github.com/tecc/rollup-plugin-import-data-uri
- Owner: tecc
- License: mit
- Created: 2022-09-06T22:33:24.000Z (over 2 years ago)
- Default Branch: dev
- Last Pushed: 2022-09-06T23:25:15.000Z (over 2 years ago)
- Last Synced: 2024-10-28T16:12:05.856Z (3 months ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rollup-plugin-import-data-uri
A simple plugin to import any file as a data URI.
Compatible with Rollup and Vite.
This plugin is *not* the same as [`@rollup/plugin-data-uri`](https://npmjs.com/package/@rollup/plugin-data-uri) - this plugin creates data URIs and exports them, whilst `@rollup/plugin-data-uri` allows you to import raw code from data URIs.
## Usage
### Configuration
#### Vite
```js
// vite.config.js
import dataURIPlugin from 'rollup-plugin-import-data-uri';export default {
plugins: [dataURIPlugin(), /* other plugins */],
/* also the rest of your configuration */
}
```### Example
If you're using Vite, the following would give you a URL to the image.
```js
import IMAGE from './image.png';
```Appending `?data-uri` to the end of the import would make it a string containing a data URI:
```js
import IMAGE from './image.png?data-uri';
```This is suitable for embedding images.
## Licence
This project is licensed under the MIT licence.
See the full licence text [here](./LICENCE).