0.1.6-beta.1 • Published 1 year ago

unplugin-vue-image-test v0.1.6-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

unplugin-vue-image

NPM version

Install

npm i unplugin-vue-image -D
// vite.config.ts
import Image from 'unplugin-vue-image/vite'

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

Example: playground/

// rollup.config.js
import Image from 'unplugin-vue-image/rollup'

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

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

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

This module works for both Nuxt 2 and Nuxt Vite

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

Usage

unplugin-vue-image auto import your image from assets/images by default to your Vue component.

You can only use image variables using camelCase.

--- aseets
  --- images
    --- logo.png
--- App.vue
--- src/App.vue ---
<template>
  <div>
    <img :src="Logo">
  </div>
</template>

Credits

This plugin was inspired by vite-plugin-vue-images, it's an enhanced version of it.

License

MIT