npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ngxstaticgenerator

v0.13.0

Published

Static html files generator for Angular Universal apps

Readme

NgxStaticGenerator

NgxStaticGenerator is a highly configurable static HTML generator for Angular Universal apps.

Server side rendering is fast. Pre-rendered static files are faster.

Prerequisites

NgxStaticGenerator requires a working Angular Universal app to fetch on the localhost. For more info on how to implement universal rendering in an Angular app, see the official guide.

A working javascript server file to be invoked via node.

Configuration

Place in you project folder a ngxsg.config.json file with the following options:

| Option | Type | Description | Default | |----------------------|----------|------------------------------------------------------------------------|---------| | supportedLangsPath | string | optional - path to the [".ts"-".js"] file with the list of supported languages. For more info see the next paragraph langs config | undefined | | routesPath | string | required - path to the [".ts"-".js"] file with the list of the app's Routes. For more info see the next paragraph routes config | undefined | | serverDir | string | optional - name of the directory in which the server file is located. It must be a subdirectory of the project folder | dist | | serverFile | string | optional - name of the server file to be executed via node to generate the server-side rendered static files | server.js | | baseUrl | string | optional - base URL to be fetched | http://localhost:3000/ | | destinationFolder | string | optional - name of the directory in which the generated static files will be saved | static | | extension | string | optional - extension of the static files to be created | .html |

Langs config

If a path is specified in the ngxsg.config.json, the .ts file must export an obect with the property applangs of Type Array<LangDetails>.

The expected url of paths should be :lang/**.

If omitted, the files will be fetched without a :lang parameter.

interface LangDetails extends Object {
  key: string;
}

See the example file in test-app/src/app/core/translate-config/applangs.constant.ts.

Routes config

The .ts file specified in the ngxsg.config.json file must export an obect with the property routes of Type Routes:

import { Routes } from '@angular/router';

See the example file in test-app/src/app/core/app-routing/routes.constant.ts.

Installation Instructions

NgxStaticGenerator should be installed as a general module.

npm install -g ngxstaticgenerator

Usage

Create a ngxsg.config.json file and set the desired options.

Run ngxsg in your project folder.

See how it works for more info on how the generator works.

How it works

NgxStaticGenerator loops all languages set via supportedLangsPath and all paths set via routesPath and fetches the response from the server.

NgxStaticGenerator will fetch urls formatted like so: [baseUrl]/[lang]/[path]. The response should contain the fully rendered html code of each page.

NgxStaticGenerator gets the response of each fetched url and stores it in a file in [destinationFolder]/[lang]/[path].[extension]. The file is minified with html-minifier.

You can then serve html static files. Your server (Apache, NodeJS, whatever) should send to the client, for each supported language, the static file correspondign to the request. Once fully loaded, each static file will include your full Angular app.

Improvements towards v. 1.0.0

  • add ability to specify the name of the object to be imported from the .ts file specified via supportedLangsPath and routesPath;
  • add ability to specify the pattern of the URL to be fetched.
  • add ability to provide the URL to be fetched via the ngxsg.config.json as an Array<string>.
  • add ability to disable minification of the html static file.