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

spa-config-gen

v1.0.3

Published

Generate configuration files for deploying Single Page Applications (SPAs) with proper routing support for .htaccess and nginx.conf.

Readme

spa-config-gen

License
Generate configuration files for deploying Single Page Applications (SPAs) with proper routing support for popular reverse proxies like Apache and Nginx.

Features

  • Generates .htaccess for Apache.
  • Generates nginx.conf for Nginx.
  • Supports additional configurations for reverse proxies such as Caddy, Traefik, and HAProxy.
  • Customizable output directory and server type.
  • Simple CLI interface for quick usage.

Installation

You can install the package globally using npm:

npm install -g spa-config-gen

Or add it to your project as a development dependency:

npm install --save-dev spa-config-gen

Usage

CLI Usage

Run the following command in your terminal:

spa-config-gen [options]

Options

| Option | Alias | Description | Default | |--------------------|-------|------------------------------------------------------------------|--------------| | --server | -s | Specify the server type (apache, nginx, caddy, traefik, haproxy). | apache | | --dir <directory>| -d | Specify the output directory for the configuration file. | build | | --help | | Display help information. | N/A | | --version | -v | Display the current version of the package. | N/A |

Examples

Generate .htaccess for Apache

spa-config-gen --server apache --dir dist

Generate nginx.conf for Nginx

spa-config-gen -s nginx -d build

Show Help

spa-config-gen --help

Show Version

spa-config-gen -v

How It Works

  1. The tool reads your specified options from the CLI.
  2. It validates the provided output directory.
  3. Based on the selected server type, it generates the appropriate configuration file (.htaccess, nginx.conf, etc.) in the specified directory.

Supported Reverse Proxies

  • Apache: Generates .htaccess for SPAs with fallback to index.html.
  • Nginx: Generates nginx.conf with try_files for SPA routing.
  • Caddy: Generates Caddyfile for SPAs.
  • Traefik: Generates configuration for SPAs in traefik.yml.
  • HAProxy: Generates haproxy.cfg for SPAs.

File Structure

spa-config-gen/
├── src/
│   ├── configs/
│   │   ├── apache.js
│   │   ├── nginx.js
│   │   ├── caddy.js
│   │   ├── traefik.js
│   │   └── haproxy.js
│   ├── generate.ts
│   ├── help.ts
│   └── index.ts
├── dist/
│   └── (Compiled JavaScript files)
├── package.json
├── tsconfig.json
├── README.md
└── LICENSE

Development

Build the Project

Compile the TypeScript source code to JavaScript:

npm run build

Test the CLI

Run the generated script:

node dist/index.js --help

Contributing

Contributions are welcome! Feel free to fork the repository and submit a pull request. For major changes, please open an issue first to discuss your idea.

License

This project is licensed under the MIT License.

Questions or Feedback?

Feel free to open an issue on GitHub if you have any questions or feedback.