diff --git a/.changeset/perfect-bananas-play.md b/.changeset/perfect-bananas-play.md new file mode 100644 index 000000000..e799da10e --- /dev/null +++ b/.changeset/perfect-bananas-play.md @@ -0,0 +1,6 @@ +--- +"@shopware-ag/meteor-component-library": patch +"nuxt-app": patch +--- + +Made DeviceHelper Vue plugin SSR-friendly diff --git a/examples/nuxt-app/app.vue b/examples/nuxt-app/app.vue index 162b3793d..a8a10638c 100644 --- a/examples/nuxt-app/app.vue +++ b/examples/nuxt-app/app.vue @@ -20,6 +20,8 @@ + + @@ -262,6 +264,7 @@ import { MtModalTrigger, MtModalAction, MtText, + MtTabs, } from "@shopware-ag/meteor-component-library"; import SwBlockStack from "./components/sw-block-stack.vue"; diff --git a/examples/nuxt-app/nuxt.config.ts b/examples/nuxt-app/nuxt.config.ts index 629d52c81..eefe8991a 100644 --- a/examples/nuxt-app/nuxt.config.ts +++ b/examples/nuxt-app/nuxt.config.ts @@ -5,4 +5,5 @@ export default defineNuxtConfig({ host: '127.0.0.1', port: 3000, }, + ssr: true, }); diff --git a/examples/nuxt-app/plugins/meteor.ts b/examples/nuxt-app/plugins/meteor.ts new file mode 100644 index 000000000..9e1d47ec2 --- /dev/null +++ b/examples/nuxt-app/plugins/meteor.ts @@ -0,0 +1,5 @@ +import { DeviceHelperPlugin } from '@shopware-ag/meteor-component-library' + +export default defineNuxtPlugin((nuxtApp) => { + nuxtApp.vueApp.use(DeviceHelperPlugin) +}) diff --git a/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-chromium-linux.png b/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-chromium-linux.png index de74f7ca4..1589d8d15 100644 Binary files a/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-chromium-linux.png and b/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-chromium-linux.png differ diff --git a/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-firefox-linux.png b/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-firefox-linux.png index e5207adb2..955c56f13 100644 Binary files a/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-firefox-linux.png and b/examples/nuxt-app/tests/smoke.spec.ts-snapshots/renders-an-example-page-1-firefox-linux.png differ diff --git a/packages/component-library/src/helper/device.helper.js b/packages/component-library/src/helper/device.helper.js index 4eedeba6f..25ef84381 100644 --- a/packages/component-library/src/helper/device.helper.js +++ b/packages/component-library/src/helper/device.helper.js @@ -9,6 +9,11 @@ import { debounce } from "lodash-es"; function DeviceHelper() { this.listeners = []; + // do not register the resize event listener on the server + if (typeof window === "undefined") { + return; + } + window.addEventListener("resize", this.resize.bind(this)); }