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.
Maintainers
Readme
spa-config-gen
Generate configuration files for deploying Single Page Applications (SPAs) with proper routing support for popular reverse proxies like Apache and Nginx.
Features
- Generates
.htaccessfor Apache. - Generates
nginx.conffor 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-genOr add it to your project as a development dependency:
npm install --save-dev spa-config-genUsage
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 distGenerate nginx.conf for Nginx
spa-config-gen -s nginx -d buildShow Help
spa-config-gen --helpShow Version
spa-config-gen -vHow It Works
- The tool reads your specified options from the CLI.
- It validates the provided output directory.
- 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
.htaccessfor SPAs with fallback toindex.html. - Nginx: Generates
nginx.confwithtry_filesfor SPA routing. - Caddy: Generates
Caddyfilefor SPAs. - Traefik: Generates configuration for SPAs in
traefik.yml. - HAProxy: Generates
haproxy.cfgfor 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
└── LICENSEDevelopment
Build the Project
Compile the TypeScript source code to JavaScript:
npm run buildTest the CLI
Run the generated script:
node dist/index.js --helpContributing
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.
