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 🙏

© 2024 – Pkg Stats / Ryan Hefner

next-htaccess-generator

v1.0.3

Published

This is a simple package to generate htaccess file from next build.

Downloads

160

Readme

Node .htaccess Generator

This project simplifies the process of creating an .htaccess file for Apache web servers using Node.js. It is specifically designed for Next.js projects but can be adapted for other static site generators as well. The .htaccess file generated by this tool enables clean and SEO-friendly URLs for your static website.

Installation

To install the package as a development dependency, run the following command in your terminal:

npm install next-htaccess-generator --save-dev

Configuration

Before using the generator, you need to configure it by creating a jay.config.json file at the root of your project folder. This file should contain the following properties:

{
  "buildPath": "./out",
  "include404": false,
  "outputPath": "out"
}
  • buildPath: Specifies the directory where your Next.js static build is located (e.g., ./out).
  • include404: A boolean value indicating whether to include rewrite rules for 404 pages. Set it to false if you want to exclude 404 pages.
  • outputPath: Defines the path where the generated .htaccess file should be saved.

Usage

After configuring the jay.config.json file, you can add a script to your package.json to generate the .htaccess file:

"scripts": {
  "build-htaccess": "next-htaccess-generator build"
}

To generate the .htaccess file, run the following command:

npm run build-htaccess

This command scans the directory specified in buildPath for HTML files, generates URL rewrite rules for each file, and saves them to the outputPath directory.

How it Works

The generator script follows these steps:

  1. Reads the configuration from the jay.config.json file.
  2. Recursively scans the specified buildPath directory and collects all HTML file paths.
  3. Generates Apache URL rewrite rules for each HTML file.
  4. Optionally adds a catch-all rule to redirect unmatched URLs (unless include404 is set to true).
  5. Writes the generated rules to an .htaccess file in the specified outputPath directory.

The resulting .htaccess file can be placed in the root directory of your Apache web server, enabling clean and SEO-friendly URLs for your Next.js static build.