Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
angular-prerender
Advanced tools
An experimental command line tool to prerender an Angular App.
This command line tool is meant to simplify the build process of static Angular apps. It works by analyzing the config file created by the Angular CLI. It looks for a client and server app target defined in the angular.json file. It does then execute the server side rendering for each route and merges the ouput into the static build for the client.
angular-prerender is available on npm. It will most likely be a dev dependency of your project. The command to install it will then look like this:
npm install angular-prerender --save-dev
In case you used all the default settings of the CLI angular-prerender will be able to pick up all the necessary information on its own and can be executed by simply calling it on the command line.
angular-prerender
It is also possible to skip the explicit installation of angular-prerender and instead run it with npx like this:
npx angular-prerender
This is a complete example which will generate a very basic static Angular app called "universe".
npx --package @angular/cli ng new universe --routing
cd universe
ng generate universal --client-project universe
npm install angular-prerender --save-dev
ng build
ng run universe:server
angular-prerender
In some scenarios angular-prerender will not be able to grab all the information by analyzing the angular.json file alone. In that case you can help it by specifying some command line arguments.
This lets you specify the name of the target of your client app. The Angular CLI will normally call it "build" and this is also used as a default value.
The config option expects a path (including the filename) to the angular.json file of your project. By default it will look for it in the current working directory.
Some URLs of your app might accept parameters. This option can be used to tell angular-prerender about the possible values those parameters could have. It expects a stringified JSON value which can be described with this TypeScript interface:
interface IParameterValuesMap {
[ segment: string ]: string[];
}
Lets imagine your app has a route with a :name
parameter in it: /team/:name
. A call to angular-prerender like this would render two routes by replacing the parameter with the given values:
angular-prerender --parameter-values '{":name":["amelia","oliver"]}'
/team/amelia
/team/oliver
This lets you specify the name of the target of your server app. The Angular CLI will normally call it "server" and this is also used as a default value.
This command line tool is only possible by bringing together the great power of Angular Universal (which is now on its way into the main Angular repository) and Guess.js (which provides an excellent parser to retrieve the routes of an Angular app).
FAQs
A command line tool to prerender Angular Apps.
The npm package angular-prerender receives a total of 90 weekly downloads. As such, angular-prerender popularity was classified as not popular.
We found that angular-prerender demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.