@canner/statics
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

static

Configuration

rewrites: you can specify custom route recognition for your application by supplying an object to the routes key. Use a single star * to replace one URL segment or a double star to replace an arbitrary piece of URLs. This works great for single page apps. An example:

{
  "rewrites": [
    {"source":"app/**","destination":"/application.html"},
    {"source":"projects/*/edit","destination":"/projects.html"}
  ]
}

redirects: you can specify certain url paths to be redirected to another url by supplying configuration to the redirects key. Path matching is similar to using custom routes. redirects use the 301 HTTP status code by default, but this can be overridden by configuration.

{
  "redirects": [
    {"source":"/some/old/path", "destination":"/some/new/path"},
    {"source":"/apps/*", "destination":"https://www.app.com", "type": 302}
  ]
}

Route segments are also supported in the redirects configuration. Segmented redirects also support custom status codes (see above):

{
  "redirects": [
    {"source":"/old/:segment/path", "destination":"/new/path/:segment"}
  ]
}

In this example, /old/custom-segment/path redirects to /new/path/custom-segment

headers: Superstatic allows you to set the response headers for certain paths as well:

{
  "headers": [
    {
      "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
      "headers" : [{
        "key" : "Access-Control-Allow-Origin",
        "value" : "*"
      }]
    }, {
      "source" : "**/*.@(jpg|jpeg|gif|png)",
      "headers" : [{
        "key" : "Cache-Control",
        "value" : "max-age=7200"
      }]
    }, {
      "source" : "404.html",
      "headers" : [{
        "key" : "Cache-Control",
        "value" : "max-age=300"
      }]
    }]
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @canner/statics

Weekly Downloads

1

Version

1.1.1

License

MIT

Last publish

Collaborators

  • wwwy3y3
  • cannerbot