@sonicgarden/next-csr-rewrites-generator

1.3.1 • Public • Published

next-csr-rewrites-generator

Deploy helper command to generate rewrite rules for Next.js CSR application

Installation

yarn add @sonicgarden/next-csr-rewrites-generator

Usage

Add this command to your deployment script (The following is for deploying to firebase hosting)

package.json:

"scripts": {
  "deploy": "next build && next export && next-csr-rewrites-generate --format firebase && firebase deploy"
}

Note: of course, you can alos run this command manually!

Command usage

next-csr-rewrites-generate

  Deploy helper command to generate rewrite rules for Next.js CSR application 

Options

  -f, --format firebase   Format type                                                           
  -o, --output filepath   Output file path. (If omitted, the original file will be overwritten) 
  -h, --help              Show usage 

Generated hosting rewrite rules

When the following files exist in the deploy directory

index.html
hoge/[hogeId].html
fuga/[fugaId].html

The following rewrite rules will be added to firebase.json (cleanUrls will be added together)

{
  "hosting": {
    "rewrites": [
      {
        "source": "/hoge/:hogeId",
        "destination": "/hoge/[hogeId].html"
      },
      {
        "source": "/fuga/:fugaId",
        "destination": "/fuga/[fugaId].html"
      }
    ],
    "cleanUrls": true
  }
}

Note: rewrite rules other than dynamic routing will not be updated.

Readme

Keywords

none

Package Sidebar

Install

npm i @sonicgarden/next-csr-rewrites-generator

Weekly Downloads

199

Version

1.3.1

License

MIT

Unpacked Size

5.99 kB

Total Files

4

Last publish

Collaborators

  • latica.jp
  • aki77
  • mat_aki
  • tochi
  • interu
  • t-kojima
  • kontikun
  • hiropon