-
Notifications
You must be signed in to change notification settings - Fork 519
Angular: Prerendering does not work when app is published #1388
Comments
I did the same for Angular 5.0.2 and experiencing same issue. please provide a solution or workaround for this. |
me too, I don't know why that is doing. |
+1 |
At the top of your webpack.js file do you have referenced? Angular 5 or Angular 4 Also make sure you have upgraded to "ngtools/webpack@1.8.3". Then update webpack.config.vendor.js with an additional plugin However, then you will have a new issue.
NodeInvocationException: No NgModule metadata found for 'AppModule'.
Error: No NgModule metadata found for 'AppModule'.
at NgModuleResolver.module.exports.NgModuleResolver.resolve
|
@justin-ruffin Thanks for the hint for the additional plugin, but replacing one issue with another issue does not help in the end ;-) |
It's possible my secondary issue is being caused by a custom configuration. Does adding |
@justin-ruffin |
Just tried it myself. I also get the error |
Angular 5 includes breaking changes (versus Angular 4) meaning that the code for server-side rendering has to be very different. As such the existing template can't be upgraded to Angular 5 as simply as that, except if you turn off server-side rendering. We're working on an Angular 5 template here: #1288 (comment) |
Angular: Prerendering does not work when app is published on server, does not display dynamic data HTML tags on ViewSource page. On Local host It is working fine. I've tried lot but didn't find anything. |
The problem
Prerendering does not work when a web application (based on the default Angular template) is upgraded to Angular 5.
Disclaimer:
I'm not sure who can fix this problem. Maybe it's a problem of angular-cli.
Steps to reproduce:
Create new project using default Angular template of VS 2017
Create a new "ASP.NET Core Web Application" using the Angular template (Target ".NET Core" with ASP.NET Core 2.0).

I'm using VS 2017 in version 15.4.4
Upgrade to Angular 5
Now I upgraded to Angular 5 and updated all other packages. This results in the following package.json:
Fix Webpack issue
If you publish the application now, you will get the the following error:
Please update @angular/cli. Angular 5+ requires at least Angular CLI 1.5+
This issue is documented here:
angular/angular-cli#8333 (comment)
angular/angular#19913
It can be fixed by updating
webpack.config.js
.The
AotPlugin
has to be replaced with theAngularCompilerPlugin
.Now publishing the app is possible without any errors.
Run the application
If you execute the published application with
dotnet MyApplication.dll
and visit the website you will see the following error in the browser:The log shows the following error:
Workaround
The problem can be "hidden" if prerendering is disabled. When
Views\Home\Index.cshtml
is changed from<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
to
<app>Loading...</app>
you are able to use the published app, but of course without server side prerendering.
Other ideas
If you look at the source code of
AngularCompilerPlugin
, you can find an option calledplatform
(see angular_compiler_plugin.tsSetting that option in
webpack.config.js
did not result in any improvements.Source code
Here is the full source code of my demo application: Issue_Angular5_Publish.zip
The text was updated successfully, but these errors were encountered: