Skip to content

Commit

Permalink
fix: dev environment variable undefined (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Oct 11, 2024
1 parent c5b16ca commit bd6fa4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ export const MotionPlugin = {
const variants = options.directives[key] as MotionVariants<any>

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

// Register the custom `v-motion-${key}` directive
Expand Down
4 changes: 2 additions & 2 deletions src/utils/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function setupMotionComponent(
[key: number]: MotionInstance<string, MotionVariants<string>>
}>({})

const customPresets = inject<Record<string, Variant>>(CUSTOM_PRESETS)
const customPresets = inject<Record<string, Variant>>(CUSTOM_PRESETS, {})

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

// Replay animations on component update Vue
if (import.meta.env.DEV) {
if (import.meta.dev) {
// Validate passed preset
if (
props.preset != null
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineConfig } from 'vite'

export default defineConfig({
root: __dirname,
define: {
dev: JSON.stringify(false),
},
test: {
environment: 'happy-dom',
include: ['./tests/**/*.spec.ts'],
Expand Down

0 comments on commit bd6fa4d

Please sign in to comment.