Coder Social home page Coder Social logo

unplugin-vue-image's Introduction

unplugin-vue-image

NPM version

Install

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

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

Example: playground/


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

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


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


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

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// 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

unplugin-vue-image's People

Contributors

dependabot[bot] avatar zyyv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

unplugin-vue-image's Issues

Feature: path configrtable

I think this path assets/images maybe configurable.

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

export default defineConfig({
  plugins: [
    Image({ path:"/static/images" }),
  ],
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.