docs: add .nuxtrc documentation (#31093)

This commit is contained in:
Alex Liu 2025-02-24 18:54:38 +08:00 committed by GitHub
parent 74ffa8db80
commit 4f122ea251
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 9 deletions

View File

@ -0,0 +1,50 @@
---
title: ".nuxtrc"
description: "The .nuxtrc file allows you to define nuxt configurations in a flat syntax."
head.title: ".nuxtrc"
navigation.icon: i-ph-file
---
The `.nuxtrc` file can be used to configure Nuxt with a flat syntax. It is based on [`unjs/rc9`](https://github.com/unjs/rc9).
::tip
For more advanced configurations, use [`nuxt.config`](/docs/guide/directory-structure/nuxt-config).
::
## Usage
```bash [.nuxtrc]
# Disable SSR
ssr=false
# Configuration for `@nuxt/devtools`
devtools.enabled=true
# Add Nuxt modules
modules[]=@nuxt/image
modules[]=nuxt-security
```
If present, the properties in the `nuxt.config` file will overwrite the properties in `.nuxtrc` file.
::read-more{to="/docs/api/configuration/nuxt-config"}
Discover all the available options in the **Nuxt configuration** documentation.
::
## Global `.nuxtrc` File
You can also create a global `.nuxtrc` file in your home directory to apply configurations globally.
- On macOS/Linux, this file is located at:
```md
~/.nuxtrc
```
- On Windows, it is located at:
```md
C:\Users\{username}\.nuxtrc
```
This global `.nuxtrc` file allows you to define default settings that apply to all Nuxt projects on your system. However, project-level `.nuxtrc` files will override these global settings, and `nuxt.config` will take precedence over both.

View File

@ -31,12 +31,4 @@ export default defineNuxtConfig({
Discover all the available options in the **Nuxt configuration** documentation. Discover all the available options in the **Nuxt configuration** documentation.
:: ::
To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/guide/directory-structure/env), [`.nuxtignore`](/docs/guide/directory-structure/nuxtignore) and `.nuxtrc` dotfiles. To ensure your configuration is up to date, Nuxt will make a full restart when detecting changes in the main configuration file, the [`.env`](/docs/guide/directory-structure/env), [`.nuxtignore`](/docs/guide/directory-structure/nuxtignore) and [`.nuxtrc`](/docs/guide/directory-structure/nuxtrc) dotfiles.
The `.nuxtrc` file can be used to configure Nuxt with a flat syntax. It is based on [`unjs/rc9`](https://github.com/unjs/rc9).
``` [.nuxtrc]
ssr=false
```
If present the properties in `.nuxtrc` file will overwrite the properties in the `nuxt.config` file.