Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

roots-netlify

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roots-netlify

A roots extension for configuring netlify

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

Roots Netlify

npm tests dependencies Coverage Status

A roots extension for creating Netlify configuration files.

Note: This project is in early development, and versioning is a little different. Read this for more details.

Why Should You Care?

Netlify is a great static hosting platform that allows developers to add powerful features to their static sites, like redirects & rewrites and headers & basic auth.

This abstracts Netlify's config files into your app.coffee with the rest of your configs so they can be one big happy family. This also allows you to create different Netlify configs based on your roots environment.

It's also a common roots convention to start files with an _ to ignore them during compilation. Since Netlify would normally be configured with a _headers and _redirects file, using this extension allows you keep that nice clean convention throughout the whole project.

Installation & Usage

  • make sure you are in your roots project directory
  • npm install roots-netlify --save
  • modify your app.coffee file to include the extension, as such
netlify = require 'roots-netlify'

module.exports =
  extensions: [
    netlify
      redirects: [
        '/news /blog 200'
        '/news/:year/:month:/:date/:slug /blog/:year/:month/:date/:story_id 200'
        '/news/* /blog/:splat 200'
        '/redirect / 301'
        '/temp_redirect / 302'
        '/ecommerce /closed 404'
      ]
      headers:
        '/protected/path':
          'Cache-Control': 'max-age: 3000'
          'Basic-Auth': 'username:password'
        '/*':
          'X-Frame-Options': 'DENY'
          'X-XSS-Protection': '1; mode=block'
  ]

Read the Netlify documentation on redirects and headers to learn more.

The redirects property accepts an array of redirects or rewrite rules (in order) with their respective HTTP code appended at the end as described in Netlify's documentation.

Promises

Instead of passing the regular options object into the extension, you can also pass a promise for an options object in case you need to perform any asynchronous work (such as loading a file or making an http request) before configuring roots-netlify.

fs     = require 'fs'
nodefn = require 'when/node'
yaml   = require 'js-yaml'

config = nodefn.call(fs.readFile, 'config.yaml')
  .then (contents) -> yaml.safeLoad(contents)

module.exports =
  extensions: [
    netlify(config)
  ]

License & Contributing

Keywords

FAQs

Package last updated on 12 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc