
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@nuxtjs/netlify-files
Advanced tools
Nuxt module to create new _headers, _redirects and netlify.toml files for Netlify or to use existing ones
Nuxt module to create new _headers, _redirects and netlify.toml files for Netlify or to use existing ones
@nuxtjs/netlify-files
dependency to your projectyarn add --dev @nuxtjs/netlify-files # or npm install --save-dev @nuxtjs/netlify-files
@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 */ }]
]
}
:warning: 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
.
export default {
buildModules: [
'@nuxtjs/netlify-files'
],
netlifyFiles: {
/* module options */
}
}
copyExistingFiles
Boolean
true
Enable/disable copying of existing files.
existingFilesDirectory
String
srcDir
The directory where your _headers, _redirects and netlify.toml files that should be copied are located.
netlifyToml
Object
or Function
(must return Object
)undefined
Object to create a netlify.toml
from. If set, netlify.toml
will not be copied, but programmatically created instead.
The module will look for _headers
, _redirects
and netlify.toml
files and will copy them 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, _redirects and netlify.toml files are located
}
}
netlify.toml
For netlify.toml
, instead of just copying it, it is also possible to create a new one. This could be useful if certain configurations need to be set dynamically.
Since with netlify.toml
also redirects and headers can be set, using this option makes it possible to dynamically create those as well, making _redirects
and _headers
files redundant.
Note that if netlifyToml
is set, the module will create the new toml directly in the destination folder. It will ignore the netlify.toml (if it does exist) in the source folder.
export default {
netlifyFiles: {
netlifyToml: {
build: {
environment: { FOO: process.env.FOO }
},
headers: [
{
for: '/*',
values: { 'X-XSS-Protection': '1; mode=block' }
}
],
redirects: [
{
from: '/old',
to: '/new',
status: 302
}
]
}
}
}
Copyright (c) Nuxt Community
FAQs
Nuxt module to create new _headers, _redirects and netlify.toml files for Netlify or to use existing ones
We found that @nuxtjs/netlify-files demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.