unplugin-image
v0.2.1
Published
A universal bundler plugin which imports JPG, PNG, GIF, SVG, and WebP files.
Downloads
5
Maintainers
Readme
unplugin-image
🍣 A universal bundler plugin which imports JPG, PNG, GIF, SVG, and WebP files.
Install
npm i -D unplugin-image
// vite.config.ts
import UnpluginImage from 'unplugin-image/vite'
export default defineConfig({
plugins: [
{
...UnpluginImage({ /* options */ }),
enforce: 'pre',
},
],
})
Example: playground/
// rollup.config.js
import UnpluginImage from 'unplugin-image/rollup'
export default {
plugins: [
UnpluginImage({ /* options */ }),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-image/webpack')({ /* options */ })
]
}
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-image/nuxt', { /* options */ }],
],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-image/webpack')({ /* options */ }),
],
},
}
// esbuild.config.js
import { build } from 'esbuild'
import UnpluginImage from 'unplugin-image/esbuild'
build({
plugins: [UnpluginImage()],
})
Usage
Options
For all options please refer to docs.
This plugin accepts all @rollup/plugin-image options.