Skip to content

Commit bd6fa4d

Browse files
authored
fix: dev environment variable undefined (#236)
1 parent c5b16ca commit bd6fa4d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/plugin/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ export const MotionPlugin = {
3232
const variants = options.directives[key] as MotionVariants<any>
3333

3434
// Development warning, showing definitions missing `initial` key
35-
if (!variants.initial && __DEV__) {
36-
console.warn(`Your directive v-motion-${key} is missing initial variant!`)
35+
if (!variants.initial && import.meta.dev) {
36+
console.warn(
37+
`Your directive v-motion-${key} is missing initial variant!`,
38+
)
3739
}
3840

3941
// Register the custom `v-motion-${key}` directive

src/utils/component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function setupMotionComponent(
122122
[key: number]: MotionInstance<string, MotionVariants<string>>
123123
}>({})
124124

125-
const customPresets = inject<Record<string, Variant>>(CUSTOM_PRESETS)
125+
const customPresets = inject<Record<string, Variant>>(CUSTOM_PRESETS, {})
126126

127127
// Preset variant or empty object if none is provided
128128
const preset = computed(() => {
@@ -195,7 +195,7 @@ export function setupMotionComponent(
195195
})
196196

197197
// Replay animations on component update Vue
198-
if (import.meta.env.DEV) {
198+
if (import.meta.dev) {
199199
// Validate passed preset
200200
if (
201201
props.preset != null

vite.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { defineConfig } from 'vite'
33

44
export default defineConfig({
55
root: __dirname,
6+
define: {
7+
dev: JSON.stringify(false),
8+
},
69
test: {
710
environment: 'happy-dom',
811
include: ['./tests/**/*.spec.ts'],

0 commit comments

Comments
 (0)