/netlify-files-module

Nuxt module to create new _headers and _redirects files for Netlify or to use existing ones

Primary LanguageJavaScriptMIT LicenseMIT

@nuxtjs/netlify-files

npm version npm downloads Github Actions CI Codecov License

Nuxt module to create new _headers and _redirects files for Netlify or to use existing ones

📖 Release Notes

Setup

  1. Add @nuxtjs/netlify-files dependency to your project
yarn add --dev @nuxtjs/netlify-files # or npm install --save-dev @nuxtjs/netlify-files
  1. Add @nuxtjs/netlify-files to the buildModules section of nuxt.config.js
export default {
  buildModules: [
    // Simple usage
    '@nuxtjs/netlify-files',

    // With options
    ['@nuxtjs/netlify-files', { /* module options */ }]
  ]
}

⚠️ If you are using Nuxt < v2.9 you have to install the module as a dependency (No --dev or --save-dev flags) and use modules section in nuxt.config.js instead of buildModules.

Using top level options

export default {
  buildModules: [
    '@nuxtjs/netlify-files'
  ],
  netlifyFiles: {
    /* module options */
  }
}

Options

copyExistingFiles

  • Type: Boolean
  • Default: true

Enable/disable copying of existing files.

existingFilesDirectory

  • Type: String
  • Default: srcDir

The directory where your _headers and _redirects file is located.

Usage

Currently, the module will look for _headers and _redirects files and will copy into the generate folder (default: dist) after static generation. If you have them directly in your project folder, you don't have to do anything else. In case the files are somewhere else you can configure the directory (see below)

export default {
  netlifyFiles: {
    existingFilesDirectory: 'path/to/nuxt/directory', // The directory where your _headers and _redirects file is located
  }
}

License

MIT License

Copyright (c) Nuxt Community