- Notifications
You must be signed in to change notification settings - Fork 433
/
Copy pathboot.server.PRODUCTION.ts
37 lines (32 loc) · 1.41 KB
/
boot.server.PRODUCTION.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import'zone.js/dist/zone-node';
import'./polyfills/server.polyfills';
import{enableProdMode}from'@angular/core';
import{createServerRenderer}from'aspnet-prerendering';
// Grab the (Node) server-specific NgModule
const{ AppModuleNgFactory }=require('./app/app.module.server.ngfactory');// <-- ignore this - this is Production only
import{ngAspnetCoreEngine,IEngineOptions,createTransferScript}from'@nguniversal/aspnetcore-engine';
enableProdMode();
exportdefaultcreateServerRenderer(params=>{
// Platform-server provider configuration
constsetupOptions: IEngineOptions={
appSelector: '<app-root></app-root>',
ngModule: AppModuleNgFactory,
request: params,
providers: [
// Optional - Any other Server providers you want to pass
// (remember you'll have to provide them for the Browser as well)
]
};
returnngAspnetCoreEngine(setupOptions).then(response=>{
// Apply your transferData to response.globals
response.globals.transferData=createTransferScript({
someData:
'Transfer this to the client on the window.TRANSFER_CACHE {} object',
fromDotnet: params.data.thisCameFromDotNET// example of data coming from dotnet, in HomeController
});
return{
html: response.html,// our <app-root> serialized
globals: response.globals// all of our styles/scripts/meta-tags/link-tags for aspnet to serve up
};
});
});