vue-snotify icon indicating copy to clipboard operation
vue-snotify copied to clipboard

Add SSR support

Open pedramk opened this issue 7 years ago β€’ 4 comments

Great one! But I think it doesn't work with SSR. I'm using Nuxtjs and I couldn't add the plugin.

pedramk avatar Jan 15 '18 07:01 pedramk

For anyone wondering, in the meantime, you can do this with Nuxt.js:

nuxt.config.js

plugins: [
  {
    src: './plugins/snotify',
    ssr: false
  }
],

plugins/snotify.js

import Vue from 'vue'
import Snotify, { SnotifyPosition } from 'vue-snotify'

const options = {
  toast: {
    position: SnotifyPosition.rightTop
  }
}

Vue.use(Snotify, options)

In your template:

<no-ssr>
  <vue-snotify></vue-snotify>
</no-ssr>

And finally, under build.extend:

config.resolve.alias['vue'] = 'vue/dist/vue.common'

Little hacky to get around this for now, but better than nothing πŸ‘

alexgarrettsmith avatar May 06 '18 09:05 alexgarrettsmith

@alexgarrett I tryed you solution but nothing seems to work better.. The best I can have is object with only one install() method..

Edit : I was on the wrong template, it worked ! thank's

Thomas-Philippot avatar Sep 19 '18 14:09 Thomas-Philippot

@alexgarrett Hi. What is this code for? Is it still relevant? ([email protected])

config.resolve.alias['vue'] = 'vue/dist/vue.common'

By the way I did this ([email protected]) and It works πŸ•ΊπŸ»: In nuxt.config.js:

plugins: [
    ...
    { src: '~/plugins/vue-snotify', mode: 'client' },
    ...
  ],

Create plugins/vue-snotify.js file with:

import Vue from 'vue'
import Snotify, { SnotifyPosition } from 'vue-snotify'

const options = {
  toast: {
    position: SnotifyPosition.rightTop
  }
}

Vue.use(Snotify, options)

In layouts/default.vue:

<template>
...
     <client-only>
          <vue-snotify></vue-snotify>
     </client-only>
...
</template>

And that's all, it works for me.

altynbek07 avatar Apr 17 '20 16:04 altynbek07

@alexgarrett Hi. What is this code for? Is it still relevant? ([email protected])

config.resolve.alias['vue'] = 'vue/dist/vue.common'

By the way I did this ([email protected]) and It works πŸ•ΊπŸ»: In nuxt.config.js:

plugins: [
    ...
    { src: '~/plugins/vue-snotify', mode: 'client' },
    ...
  ],

Create plugins/vue-snotify.js file with:

import Vue from 'vue'
import Snotify, { SnotifyPosition } from 'vue-snotify'

const options = {
  toast: {
    position: SnotifyPosition.rightTop
  }
}

Vue.use(Snotify, options)

In layouts/default.vue:

<template>
...
     <client-only>
          <vue-snotify></vue-snotify>
     </client-only>
...
</template>

And that's all, it works for me.

you need to add the styles. Add this line: import "vue-snotify/styles/material.css"

theprantadutta avatar Aug 20 '20 15:08 theprantadutta