@humanspeak/svelte-motion
Version:
Framer Motion for Svelte 5. Declarative motion.<tag> components with AnimatePresence exit animations, gestures (hover, tap, drag, focus, in-view), variants, FLIP layout animations, shared-layout transitions, spring physics, and scroll-linked motion values
37 lines (36 loc) • 1.08 kB
TypeScript
import type { Plugin } from 'vite';
/**
* A Vite plugin that optimizes `@humanspeak/svelte-motion` imports for tree-shaking.
*
* Transforms `motion.div`, `motion.span`, etc. into direct component imports,
* eliminating the need to bundle all 170+ HTML/SVG element wrappers.
*
* @example
* ```ts
* // vite.config.ts
* import { svelteMotionOptimize } from '@humanspeak/svelte-motion/vite'
* import { sveltekit } from '@sveltejs/kit/vite'
* import { defineConfig } from 'vite'
*
* export default defineConfig({
* plugins: [svelteMotionOptimize(), sveltekit()]
* })
* ```
*
* Before (all 170+ wrappers bundled):
* ```svelte
* <script>
* import { motion } from '@humanspeak/svelte-motion'
* </script>
* <motion.div animate={{ opacity: 1 }}>Hello</motion.div>
* ```
*
* After (only Div.svelte bundled):
* ```svelte
* <script>
* import SvelteMotionDiv from '@humanspeak/svelte-motion/html/Div.svelte'
* </script>
* <SvelteMotionDiv animate={{ opacity: 1 }}>Hello</SvelteMotionDiv>
* ```
*/
export declare const svelteMotionOptimize: () => Plugin;