Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compatibility] Support for SSR (Nuxt, VuePress, Gridsome) #328

Closed
matthewmorek opened this issue Mar 31, 2021 · 1 comment
Closed

[Compatibility] Support for SSR (Nuxt, VuePress, Gridsome) #328

matthewmorek opened this issue Mar 31, 2021 · 1 comment
Labels
enhancement New feature or request
Projects

Comments

@matthewmorek
Copy link

After trying to implement Mapbox using this component (as well as the original vue-mapbox), I got blocked by lack of support for SSR.

The component is so problematic for SSR that even when forced to load only on the client (safeguarding with <ClientOnly/> element in Gridsome and importing it via dynamic import, it's impossible to not have unhandled promise rejection errors while building the site.

MglMap: async () =>
  await import("v-mapbox")
    .then((m) => m.MglMap)
    .catch(),

Where would one start when it comes to making this component compatible with SSR? I'll be happy to contribute, but I also noticed that there's quite a few outstanding PRs, and so I wonder whether it won't become stale.

@michisp
Copy link

michisp commented May 12, 2021

Hey,
for Nuxt I've created a mapbox.js file inside the plugins folder which registers the Components i need.
Inside the nuxt.config.js I've added this plugin in client-mode. After that you have to add the css files to the layout, page or component and you are ready to use mapbox inside the -tag

/plugins/mapbox.js

/* eslint-disable import/no-extraneous-dependencies */
import Vue from 'vue';
import {
  MglMap,
  MglGeolocateControl,
  MglGeojsonLayer,
  MglMarker,
} from 'v-mapbox';

Vue.component('MglMap', MglMap);
Vue.component('MglGeolocateControl', MglGeolocateControl);
Vue.component('MglMarker', MglMarker);
Vue.component('MglGeojsonLayer', MglGeojsonLayer);

/nuxt.config.js
plugins: [ { src: '~/plugins/mapbox', mode: 'client' }, ],

@vinayakkulkarni vinayakkulkarni added the enhancement New feature or request label May 18, 2021
@vinayakkulkarni vinayakkulkarni added this to To do in v3.x Jun 22, 2021
@matthewmorek matthewmorek closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
v3.x
To do
Development

No branches or pull requests

3 participants