unplugin-vue-auto-img
v0.2.1
Published
Automatically import images into the vue project
Downloads
280
Maintainers
Readme
unplugin-vue-auto-img
Automatically import images into the vue project
.d.ts
add them to the types property in your tsconfig.json:
{
"compilerOptions": {
// ...
"types": ["unplugin-vue-auto-img/client"]
}
}
Install
npm i unplugin-vue-auto-img
// vite.config.ts
import Images from 'unplugin-vue-auto-img/vite'
export default defineConfig({
plugins: [
Images({ /* options */ }),
],
})
Example: playground/
// rollup.config.js
import Images from 'unplugin-vue-auto-img/rollup'
export default {
plugins: [
Images({ /* options */ }),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-vue-auto-img/webpack')({ /* options */ })
]
}
// nuxt.config.js
export default defineNuxtConfig({
modules: [
['unplugin-vue-auto-img/nuxt', { /* options */ }],
],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-vue-auto-img/webpack')({ /* options */ }),
],
},
}
// esbuild.config.js
import { build } from 'esbuild'
import Images from 'unplugin-vue-auto-img/esbuild'
build({
plugins: [Images()],
})
Usage
unplugin-vue-auto-img
auto import your image from assets/images
by default to your Vue component.
You can only use image variables using camelCase.
--- assets
--- images
--- logo.png
--- App.vue
--- src/App.vue ---
<template>
<div>
<img :src="ILogo">
</div>
</template>