spatie / laravel-server-side-rendering

Server side rendering JavaScript in your Laravel application
https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php
MIT License
662 stars 63 forks source link

self is not defined #88

Closed htuzel closed 2 years ago

htuzel commented 2 years ago

I am getting this error on laravel logs:

var chunkLoadingGlobal = self[\"webpackChunk\"] = self[\"webpackChunk\"] || [];

ReferenceError: self is not defined

mreed5168 commented 2 years ago

@htuzel Try adding this to your Webpack config.

output: {
  globalObject: typeof self !== 'undefined' ? self : 'this',
}
mreed5168 commented 2 years ago

@htuzel Actually, the previous snippet will resolve the error, but SSR may not work, so I don't recommend using it. The snippet below, when added to your Webpack config, will resolve the error and builds bundles that run in any environment, so SSR will work as expected.

   output: {
      globalObject: 'this',
      libraryTarget: 'umd',
    },
spatie-bot commented 2 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.