bharney / JSStarterDocker

.Net Core 2.1 C# with React Starter Project that provides Identity Authentication and Authorization using JWT. Based on .NET Core JavaScriptServices Spa React + Redux using TypeScript. Additional support available for Docker and ARM Templating. Project uses Key Vault for secrets and EntityFrameworkCore to migrate Identity tables.
https://jsstarter.azurewebsites.net
17 stars 3 forks source link

NodeInvocationException: document is not defined on initial project startup. But fine after refreshing page (F5) #50

Open bharney opened 5 years ago

bharney commented 5 years ago

Force VS Build to wait for Webpack Completion before displaying page

bharney commented 5 years ago

Problem is associated with running the server side code before webpack is completed compilation. Additionally entire webpack is run when the webserver starts. Need to prevent this to resolve issue.

ghost commented 5 years ago

Do you think a multi-stage docker build might help with this? I'm not 100% familiar with your custom webpack build but I know the baked in Angular bundling is an after effect of successfully compiling the server code.

Would it be possible to trigger the webpack build in the Dockerfile manually before starting the server code compilation? https://docs.docker.com/develop/develop-images/multistage-build/#before-multi-stage-builds

Essentially what I'm saying is can we strip this functionality from the .csproj and put it into the Dockerfile?


<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Message Importance="high" Text="Performing npm install..." />
    <Exec Command="npm install" />
    <Message Importance="high" Text="Creating ClientApp/dist directory..." />
    <MakeDir Directories="ClientApp\dist\" />
    <Message Importance="high" Text="Creating react-loadable.json file..." />
    <WriteLinesToFile File="ClientApp\dist\react-loadable.json" Lines="{}" Overwrite="True" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.prod.js --env.prod" />
    <Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.server.prod.js --env.prod" />
```XML
bharney commented 5 years ago

@mtmulch I'd love to remove that setup from the .csproj file and into the docker build. I was trying to figure out at way to do that but no luck. I think this is one of the higher priorities for getting the project running correctly. Its a huge bug that the initial page load is an error message that requires a page refresh. Any help with trouble shooting/ PR is welcome. I would be stoked if this was resolved. 🌮

ghost commented 5 years ago

@bharney Hello friend, starting a new job this week that I might finally be able to call home and back in my own place in Chicago. I'm gonna take a look at some of this stuff soon on some nights when I'm bored.