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

gatsby-plugin-htaccess

v1.4.0

Published

gatsby-plugin-htaccess creates a customizable htaccess-file on build containing the most important default settings for performance and security.

Downloads

6,755

Readme

Gatsby Plugin Htaccess

Gatsby Plugin Htaccess creates a “.htaccess”-file every time a gatsby build is triggered. This file contains by default all basic rules specified by Apache Server Configs v2.4.0.

Additionally, the headers for HTTP caching are set as recommended by the Gatsby team: https://www.gatsbyjs.org/docs/caching/

Default output

Without any configuration the plugin will output these files:

Getting Started

  1. Install the package with npm or yarn

    npm install gatsby-plugin-htaccess

    yarn add gatsby-plugin-htaccess

  2. Add to plugins in your gatsby-config.js

module.exports = {
  plugins: ['gatsby-plugin-htaccess'],
}

Options

| Name | Type | Description | | :------------------- | :------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | RewriteBase | bool or string | Set to true, it will output RewriteBase /. You can also define a custom RewriteBase. | | https | bool | Force https. | | www | bool | Suppress/force “www” at the beginning of URLs. By default "www" is supressed. | | DisallowSymLinks | bool | By default Options +FollowSymlinks is activated. If your hoster does not allow this option, you can set DisallowSymLinks to true. | | SymLinksIfOwnerMatch | bool | You can restrict follow symlinks to owner match. | | host | string | Defines the domain, every other domain, that leads to your website, gets redirected to. Like Redirecting Domains from redirects, but without having to define the alternate hosts. | | ErrorDocument | string | Define custom ErrorDocuments. Default: ErrorDocument 404 /404/index.html | | redirect | array of objects and/or strings | Fully customized redirects: Can be defined as strings. Redirecting Domains: If there are several domains pointing to your site, you can redirect them to your main domain by setting up objects with the keys from and to. Redirects from Gatsby: Redirects from Gatsby are not automatically integrated. If you just want that, you should generally go with gatsby-plugin-htaccess-redirects. | | custom | string | Custom Rules are added at the end of the file public/.htaccess. |

Example Options:

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-htaccess',
      options: {
        RewriteBase: '/custom/',
        https: true,
        www: true,
        SymLinksIfOwnerMatch: true,
        host: 'www.mydomain.com', // if 'www' is set to 'false', be sure to also remove it here!
        ErrorDocument: `
          ErrorDocument 401 /error_pages/401.html
          ErrorDocument 404 /error_pages/404.html
          ErrorDocument 500 /error_pages/500.html
        `,
        redirect: [
          'RewriteRule ^not-existing-url/?$ /existing-url [R=301,L,NE]',
          {
            from: 'my-domain.com',
            to: 'mydomain.com',
          },
          {
            from: 'my-other-domain.com',
            to: 'mydomain.com',
          },
        ],
        custom: `
            # This is a custom rule!
            # This is a another custom rule!
        `,
      },
    },
  ],
}

Contributing

Every contribution is very much appreciated. Feel free to file bugs, feature- and pull-requests.

If this plugin is helpful for you, star it on GitHub.

Thanks

This plugin is based on gatsby-plugin-htaccess-redirects by Gatsby Central.

The htaccess-directives are taken from Apache Server Configs by H5BP.