Vasilis Tsirimokos
Vasilis Tsirimokos

Reputation: 203

Gridsome build fails when used with vue2-leaflet plugin

When running gridsome build I get window is not defined. Anyone has an example of making vue2-leaflet work with the client only option for gridsome?

Upvotes: 0

Views: 356

Answers (2)

Hermesis
Hermesis

Reputation: 176

Wrap your component inside template with <ClientOnly> tag, more info in my other answer

Upvotes: 2

HPDL
HPDL

Reputation: 11

I've been struggling with the same problem (but with other libraries) and the only solution i've found was to copy the package into src/. Something like :

cp -a node_modules/package-giving-me-headaches src/plugins

and

// main.js
import PackageGivingMeHeadaches from "~/plugins/package-giving-me-headaches"

Depending on the package, you may need to target a specific entry point :

// main.js
import PackageGivingMeHeadaches from "~/plugins/package-giving-me-headaches/src" 

You know you need to do that when Gridsome tells you :

"export 'default' (imported as 'PackageGivingMeHeadaches') was not found in '~/plugins/package-giving-me-headaches'

Edit : Yes, i know its not ideal and ugly, but i don't have time to fight for it.

Upvotes: 0

Related Questions