npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

unplugin-vue-images

v0.0.7

Published

Victor Bo's Unplugin Template.

Readme

unplugin-vue-images

NPM version

Use the image resource as a component in the vue project.

Install

npm i unplugin-vue-images
// vite.config.js
import VueImages from 'unplugin-vue-images/vite'

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

// rollup.config.js
import VueImages from 'unplugin-vue-images/rollup'

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

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

// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-vue-images/nuxt', { /* options */ }],
  ],
}

This module works for both Nuxt 2 and Nuxt Vite

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

// esbuild.config.js
import { build } from 'esbuild'
import VueImages from 'unplugin-vue-images/esbuild'

build({
  plugins: [VueImages({ /* options */ })],
})

Usage

You can learn more by looking at the examples.
vite-vue2
vite-vue3

Without

<script>
import ImageUrl from '@/assets/image.png'
</script>

<template>
  <img :src="ImageUrl" width="120" height="120">
</template>

With

<script>
import Image from '~images/image.png?width=120&height=120'
</script>

<template>
  <Image />
</template>

Note
By default this plugin will import images in the src/assets/images path. You can customize it using the dirs option.
Import rule is ~images[:alias]/filename[.extension][?attrs], So you have the flexibility to import your image resources.

Configuration

VueImages({
  // search images dirs
  // default 'src/assets/images'
  dirs: [
    // 'src/assets/images',
    // { icons: 'src/assets/icons' }
  ],

  // search images extensions
  // default ['jpg', 'jpeg', 'png', 'svg', 'webp', 'gif']
  extensions: [],

  // generate vue component version
  // support 'vue2' | 'vue3'
  // default 'vue3'
  compiler: 'vue3'
})

Support unplugin-vue-components

config

// `vite.config.ts`

import type { UserConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import VueImages from 'unplugin-vue-images/vite'
import { ImagesResolver } from 'unplugin-vue-images/resolver'

const collectionDirs = [
  'src/assets/images',
  { icons: 'src/assets/icons' },
]

const extensions = ['jpg', 'jpeg', 'png', 'svg', 'webp', 'gif']

const config: UserConfig = {
  plugins: [
    Vue(),
    VueImages({
      dirs: collectionDirs,
      extensions,
      compiler: 'vue3',
    }),
    Components({
      resolvers: [
        ImagesResolver({
          // Components Prefix
          // Only those starting with prefix will be imported automatically
          // Set to false or '' disabled
          // default: 'img'
          prefix: 'img',

          // The dirs must be the same as those in plugins
          // default: 'src/assets/images'
          dirs: collectionDirs,

          // The extensions must be the same as those in plugins
          // default: ['jpg', 'jpeg', 'png', 'svg', 'webp', 'gif']
          extensions,
        }),
      ],
    }),
  ],
}

export default config

usage

<template>
  <div>
    <img-account />
    <img-normal-password-png />
    <img-icons-name />
  </div>
</template>

Note
By default this plugin will import images in the src/assets/images path. You can customize it using the dirs option.
Usage rule is [prefix-][alias-]name[-extension], So you have the flexibility to usage generate components.

License

MIT License © 2022 Victor Bo