angular / material.angular.io

Docs site for Angular Components
http://material.angular.io
MIT License
884 stars 395 forks source link

Add server-side prerendering #169

Open jelbourn opened 7 years ago

jelbourn commented 7 years ago
amcdnl commented 7 years ago

I attempted to add app-shell rendering for PWA enhancement using ngu-app-shell, however encountered errors when trying to build.

> ngu-app-shell --module src/app/app-module.ts --out dist/index-shell.html

Unhandled Promise rejection: ENOENT: no such file or directory, open 'footer.html' ; Zone: <root> ; Task: Promise.then ; Value: { Error: ENOENT: no such file or directory, open 'footer.html'
    at Object.fs.openSync (fs.js:558:18)
    at Object.fs.readFileSync (fs.js:468:33)
    at /Users/dev/material.angular.io/node_modules/ng-pwa-tools/lib/common/ng.js:24:24
    at new ZoneAwarePromise (/Users/dev/material.angular.io/node_modules/zone.js/dist/zone-node.js:834:29)
    at FileLoader.get (/Users/dev/material.angular.io/node_modules/ng-pwa-tools/lib/common/ng.js:23:16)
    at DirectiveNormalizer._fetch (/Users/dev/material.angular.io/node_modules/@angular/compiler/bundles/compiler.umd.js:14095:43)
    at DirectiveNormalizer.normalizeTemplateOnly (/Users/dev/material.angular.io/node_modules/@angular/compiler/bundles/compiler.umd.js:14138:29)
    at DirectiveNormalizer.normalizeTemplate (/Users/dev/material.angular.io/node_modules/@angular/compiler/bundles/compiler.umd.js:14122:36)
    at CompileMetadataResolver.loadDirectiveMetadata (/Users/dev/material.angular.io/node_modules/@angular/compiler/@angular/compiler.es5.js:15121:44)
    at /Users/dev/material.angular.io/node_modules/@angular/compiler/@angular/compiler.es5.js:26692:66
jelbourn commented 7 years ago

The real problem blocking the use of platform-server here is our use of scss in styleUrls (which ngc cannot understand).

amcdnl commented 7 years ago

@jelbourn - So in the past, I've gotten around this by pre-compiling the css and copying the code to a temp dir and replacing scss to css. Would you be ok w/ an approach like that?

jelbourn commented 7 years ago

Not sure it's worth it at the moment. I think we'd get more benefit from lazy loading, which is a harder problem.

Splaktar commented 4 years ago

There are more options for this today.

Splaktar commented 4 years ago

Scully is another option for pre-rendering.