1.0.4 • Published 4 months ago

unplugin-lottie v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

unplugin-lottie

NPM version

Lottie Plugin for unplugin.

Bundler Support

NameStatus
ViteVite
RollupRollup
WebpackWebpack
NuxtNuxt
Vue CLIVue CLI
esbuildesbuild

Note

This project assumes that all of your Lottie files are in the same directory.

.
├── images
│   ├── img0.png
│   ├── img1.png
│   ├── ...
│   └── img5.png
└── data.json

Usage

// yourProjectFile.ts
import lottieFile from 'assets/your-lottie-file/data.json?lottie'
import lottie from 'lottie-web'

lottie.loadAnimation({
  container: element, // the dom element that will contain the animation
  renderer: 'svg',
  loop: true,
  autoplay: true,
  animationData: lottieFile, // the animation json object
})

Install

npm i -d unplugin-lottie
// vite.config.ts
import UnpluginLottie from 'unplugin-lottie/vite'

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

Example: playground/

// rollup.config.js
import UnpluginLottie from 'unplugin-lottie/rollup'

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

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

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

This module works for both Nuxt 2 and Nuxt Vite

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

// esbuild.config.js
import { build } from 'esbuild'
import UnpluginLottie from 'unplugin-lottie/esbuild'

build({
  plugins: [UnpluginLottie()],
})

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

5 months ago

1.0.1

5 months ago