npm

unplugin-image
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

unplugin-image

NPM version

🍣 A universal bundler plugin which imports JPG, PNG, GIF, SVG, and WebP files.

Install

npm i -D unplugin-image
Vite
// vite.config.ts
import UnpluginImage from 'unplugin-image/vite'

export default defineConfig({
  plugins: [
    {
      ...UnpluginImage({ /* options */ }),
      enforce: 'pre',
    },
  ],
})

Example: playground/


Rollup
// rollup.config.js
import UnpluginImage from 'unplugin-image/rollup'

export default {
  plugins: [
    UnpluginImage({ /* options */ }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-image/webpack')({ /* options */ })
  ]
}


Nuxt
// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    ['unplugin-image/nuxt', { /* options */ }],
  ],
})

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-image/webpack')({ /* options */ }),
    ],
  },
}


esbuild
// 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.

Package Sidebar

Install

npm i unplugin-image

Weekly Downloads

0

Version

0.2.1

License

MIT

Unpacked Size

20.5 kB

Total Files

45

Last publish

Collaborators

  • wzc520pyfm