I am using dot net core with angular 4 and webpack config.
When I am trying to get the window or document in a component or service, I am getting this error:
ReferenceError: document is not defined
ReferenceError: window is not defined
Here are the errors i am getting:
Microsoft.AspNetCore.NodeServices[0]
ERROR { ReferenceError: window is not defined
at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: window is not defined
ReferenceError: window is not defined
at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)
I am still new to the webpack stuff, anyone know how i can fix this? I need the window to handle when a window is resizing.
EDIT...
I managed to get this fixed by removing the pre render from the index.cshtml
i changed it from this:
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
to this:
<app>Loading...</app>
but now obviously pre rendering on server side won't be happening :/ thus it will slow the app boot up time, any ideas how I can fix this without loosing server side pre rendering?