question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vue-scroll-reveal in Gridsome SSR not building

See original GitHub issue

Is it possible to use vue-scroll-reveal with Gridsome? I have had it working in Nuxt with vue-scroll-reveal.js having:

import Vue from 'vue';
import VueScrollReveal from 'vue-scroll-reveal';

Vue.use(VueScrollReveal, {
	reset: false,
	class: 'v-scroll-reveal',
	duration: 500,
	distance: '20px',
	mobile: true,
	interval: 600
});

and then loading main.js with:

plugins: [{src: '~/plugins/vue-scroll-reveal', ssr: false}],

I’ve got vue-scroll-reveal working with gridsome develop but it fails to build with gridsome build because the scroll-reveal package uses another package that tries to use window or document (which you can’t access on SSR) also seen here.

on Girdsome in my main.js I have recently been using:

if (process.isClient) {
	const VueScrollReveal = () => import('vue-scroll-reveal');

	VueScrollReveal().then(scrollReveal => {
		console.log(scrollReveal);
		Vue.use(scrollReveal, {
			reset: false,
			class: 'v-scroll-reveal',
			duration: 500,
			distance: '20px',
			mobile: true,
			interval: 600
		});
	});
}

Which does actually add the VueScrollReveal into the project (I think), but then when viewing the HTML, none of the HTML elements have the v-scroll-reveal which I’ve given them. I’m guessing because on building Gridsome can’t see a use for v-scroll-reveal in HTML so it removes it maybe?

Is there any way you could add this a plugin to Gridsome or help point me in the right direction?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
u12206050commented, Jul 22, 2019

gridsome-scroll-reveal is published as a drop-in-replacement for vue-scroll-reveal

npm install gridsome-scroll-reveal -S

import GridsomeScrollReveal from 'gridsome-scroll-reveal';

export default function (Vue, { router, head, appOptions }) {
  Vue.use(GridsomeScrollReveal, {
			reset: false,
			class: 'v-scroll-reveal',
			duration: 500,
			distance: '20px',
			mobile: true,
			interval: 600
		})
}
4reactions
u12206050commented, Jul 22, 2019

Hi everyone, I currently have two separate solutions that we can publish, but only want to publish one.

1 Please vote 🚀rocket for the first one; which is simply a fork of vue-scroll-reveal that we can publish as gridsome-scroll-reveal as a simple drop in replacement. eg.

import GridsomeScrollReveal from 'gridsome-scroll-reveal';

export default function (Vue, { router, head, appOptions, isClient, isServer }) {
  Vue.use(GridsomeScrollReveal)

  …
}

2 Else vote 👀 eyes for the second; which is an extra library you include gvue-scroll-reveal that you would use like such within main.js

import VueScrollReveal from 'vue-scroll-reveal';
import GVueScrollReveal from 'gvue-scroll-reveal';

export default function (Vue, { router, head, appOptions, isClient, isServer }) {
  if(isServer) {
    Vue.use(GVueScrollReveal)
  } else Vue.use(VueScrollReveal)

  …
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't build Gridsome website with Vue2 Smooth Scroll
I've tryed a lot of approaches in main.js and my template.vue files, but I'm failing to understand the logic for adapting the solution...
Read more >
Introduction - Gridsome
Gridsome is a Vue.js powered Jamstack framework for building static generated websites & apps ... Knowing how GraphQL works is a plus, but...
Read more >
gridsome-scroll-reveal - npm
A Gridsome Vue directive to wrap @jlmake's excellent ScrollReveal library.. Latest version: 1.0.11, last published: 3 years ago.
Read more >
[Solved]-Gridsome Full Calendar build error - no SSR-Vue.js
[Solved]-Gridsome Full Calendar build error - no SSR-Vue.js ... I also was not pointing to the default object when requiring the other modules...
Read more >
Tweets with replies by gridsome.js (@gridsome ... - Twitter
We're rethinking Gridsome.js in Vite & serverless on-demand building (Incremental ... and the <ClientOnly> component for components with no SSR support.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found