Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 51 additions & 51 deletions docs/1.getting-started/3.configuration.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
---
navigation.icon: uil:wrench
description: Nuxt is configured with sensible defaults. The config file can override or extend them.
description: Nuxt налаштовано з доцільними замовчуваннями. Файл налаштувань може перевизначити або розширити їх.
---

# Configuration
# Конфігурація

By default, Nuxt is configured to cover most use cases. The [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt.config) file can override or extend this default configuration.
За промовчуванням Nuxt налаштований для покриття більшості випадків використання. Файл [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt.config) може перевизначати або розширюювати конфігурацію за промовчуванням.

## Nuxt Configuration
## Конфігурація Nuxt

The `nuxt.config.ts` file is located at the root of a Nuxt project and can override or extend the application's behavior.
Файл `nuxt.config.ts` знаходиться у корні проєкту Nuxt та може перевизначати або розширювати поведінку застосунку.

A minimal configuration file exports the `defineNuxtConfig` function containing an object with your configuration. The `defineNuxtConfig` helper is globally available without import.
Мінімальний конфегураційний файл експортує функцію `defineNuxtConfig`, що містить об'єкт з вашою конфігурацією. Хелпер `defineNuxtConfig` глобально доступний без імпорту.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
// My Nuxt config
// Моя конфігурація Nuxt
})
```

This file will often be mentioned in the documentation, for example to add custom scripts, register modules or change rendering modes.
Цей файл часто згадується в документації, наприклад, для додавання власних сценаріїв, реєстрації модулів або зміни режимів відтворення.

::alert{type=info}
Every configuration option is described in the [Configuration Reference](/docs/api/configuration/nuxt-config).
Кожний параметр конфігурації описано у [Довіднику конфігурації](/docs/api/configuration/nuxt-config).
::

::alert{type=info}
You don't have to use TypeScript to build an application with Nuxt. However, it is strongly recommended to use the `.ts` extension for the `nuxt.config` file. This way you can benefit from hints in your IDE to avoid typos and mistakes while editing your configuration.
Вам не потрібно використовувати TypeScript для створення застосунка з Nuxt. Однак настійно рекомендується використовувати розширення `.ts` для файлу `nuxt.config`. Таким чином, ви можете скористатися підказками у вашому IDE, щоб уникнути друкарських помилок та помилок під час редагування вашої конфігурації.
::

### Environment Variables and Private Tokens
### Змінні Середовища та Приватні Токени

The `runtimeConfig` API exposes values like environment variables to the rest of your application. By default, these keys are only available server-side. The keys within `runtimeConfig.public` are also available client-side.
API `runtimeConfig` надає такі значення, як змінні середовища, для решти вашої програми. За промовчуванням ці ключі доступні лише на стороні сервера. Ключі в `runtimeConfig.public` також доступні на стороні клієнта.

Those values should be defined in `nuxt.config` and can be overridden using environment variables.
Ці значення повинні бути визначені в `nuxt.config` і можуть бути перевизначені за допомогою зміних середовища.

::code-group

```ts [nuxt.config.ts]
export default defineNuxtConfig({
runtimeConfig: {
// The private keys which are only available server-side
// Приватний ключ, що доступний лише на стороні сервера
apiSecret: '123',
// Keys within public are also exposed client-side
// Публічний ключ, що також доступний на стороні клієнта
public: {
apiBase: '/api'
}
Expand All @@ -51,13 +51,13 @@ export default defineNuxtConfig({
```

```text [.env]
# This will override the value of apiSecret
# Це перевизначить значення apiSecret
NUXT_API_SECRET=api_secret_token
```

::

These variables are exposed to the rest of your application using the [`useRuntimeConfig`](/docs/api/composables/use-runtime-config) composable.
Ці змінні доступні для решти вашого застосунку за допомогою композиційної функції [`useRuntimeConfig`](/docs/api/composables/use-runtime-config).

```vue [pages/index.vue]
<script setup>
Expand All @@ -67,15 +67,15 @@ const runtimeConfig = useRuntimeConfig()

:ReadMore{link="/docs/guide/going-further/runtime-config"}

## App Configuration
## Конфігурація Застосунку

The `app.config.ts` file, located in the source directory (by default the root of the project), is used to expose public variables that can be determined at build time. Contrary to the `runtimeConfig` option, these can not be overridden using environment variables.
Файл `app.config.ts`, розташований у початковому каталозі (за промовчуванням у корені проекту), використовується для надання загальнодоступних змінних, які можна визначити під час збірки. На відміну від параметра `runtimeConfig`, їх не можна перевизначити за допомогою змінних середовища.

A minimal configuration file exports the `defineAppConfig` function containing an object with your configuration. The `defineAppConfig` helper is globally available without import.
Мінімальний конфегураційний файл експортує функцію `defineAppConfig`, що містить об'єкт з вашою конфігурацією. Хелпер `defineAppConfig` глобально доступний без імпорту.

```ts [app.config.ts]
export default defineAppConfig({
title: 'Hello Nuxt',
title: 'Привіт Nuxt',
theme: {
dark: true,
colors: {
Expand All @@ -85,7 +85,7 @@ export default defineAppConfig({
})
```

These variables are exposed to the rest of your application using the [`useAppConfig`](/docs/api/composables/use-app-config) composable.
Ці змінні доступні для решти вашого застосунку за допомогою композиційної функції [`useAppConfig`](/docs/api/composables/use-app-config).

```vue [pages/index.vue]
<script setup>
Expand All @@ -95,41 +95,41 @@ const appConfig = useAppConfig()

:ReadMore{link="/docs/guide/directory-structure/app-config"}

## `runtimeConfig` vs `app.config`
## `runtimeConfig` проти `app.config`

As stated above, `runtimeConfig` and `app.config` are both used to expose variables to the rest of your application. To determine whether you should use one or the other, here are some guidelines:
Як зазначено вище, `runtimeConfig` та `app.config` обидва використовуються для доступності змінних для решти вашого застосунку. Щоб визначити, чи варто вам використовувати те чи інше, ось кілька вказівок:

- `runtimeConfig`: Private or public tokens that need to be specified after build using environment variables.
- `app.config` : Public tokens that are determined at build time, website configuration such as theme variant, title and any project config that are not sensitive.
- `runtimeConfig`: Приватні або публічні токени, які потрібно вказати після збірки за допомогою змінних середовища.
- `app.config` : Публічні токени, яці потрібно вказати під час збірки, конфегурація веб-сайту як варіант теми, заголовок або різні налаштування проєкту, що не є конфіденційними.

Feature | `runtimeConfig` | `app.config`
-------------------------------|------------------|-------------------
Client Side | Hydrated | Bundled
Environment Variables | ✅ Yes | ❌ No
Reactive | ✅ Yes | ✅ Yes
Types support | ✅ Partial | ✅ Yes
Configuration per Request | ❌ No | ✅ Yes
Hot Module Replacement | ❌ No | ✅ Yes
Non primitive JS types | ❌ No | ✅ Yes
Особливість | `runtimeConfig` | `app.config`
-------------------------------|-----------------|-------------------
Клієнтська Сторона | Гідровано | В пакеті
Змінні Середовища | ✅ Так | ❌ Ні
Реактивність | ✅ Так | ✅ Так
Підтримака типів | ✅ Частково | ✅ Так
Зміна по Запросу | ❌ Ні | ✅ Так
Швидка Зміна Модулів | ❌ Ні | ✅ Так
Неприметивні типи JS | ❌ Ні | ✅ Так

## External Configuration Files
## Зовнішні Конфегураційні Файли

Nuxt uses `nuxt.config.ts` file as the single source of trust for configurations and skips reading external configuration files. During the course of building your project, you may have a need to configure those. The following table highlights common configurations and, where applicable, how they can be configured with Nuxt.
Nuxt використовує файл `nuxt.config.ts` як єдине джерело довіри для конфігурації та пропускає зчитування зовнішніх файлів конфігурації. Під час побудови вашого проекту у вас може виникнути необхідність їх налаштувати. У наведеній нижче таблиці висвітлено загальні конфігурації та, де це можливо, як їх можна налаштувати за допомогою Nuxt.

Name | Config File | How To Configure
|---------------------------------------------|---------------------------|-------------------------
| [Nitro](https://nitro.unjs.io/) | ~~`nitro.config.ts`~~ | Use [`nitro`](/docs/api/configuration/nuxt-config#nitro) key in `nuxt.config`
| [PostCSS](https://postcss.org) | ~~`postcss.config.js`~~ | Use [`postcss`](/docs/api/configuration/nuxt-config#postcss) key in `nuxt.config`
| [Vite](https://vitejs.dev) | ~~`vite.config.ts`~~ | Use [`vite`](/docs/api/configuration/nuxt-config#vite) key in `nuxt.config`
| [webpack](https://webpack.js.org/) | ~~`webpack.config.ts`~~ | Use [`webpack`](/docs/api/configuration/nuxt-config#webpack-1) key in `nuxt.config`
Назва | Кофігураційний Файл | Як Налаштувати
|---------------------------------------------|-------------------------|-------------------------
| [Nitro](https://nitro.unjs.io/) | ~~`nitro.config.ts`~~ | Використовуйте ключ [`nitro`](/docs/api/configuration/nuxt-config#nitro) у `nuxt.config`
| [PostCSS](https://postcss.org) | ~~`postcss.config.js`~~ | Використовуйте ключ [`postcss`](/docs/api/configuration/nuxt-config#postcss) у `nuxt.config`
| [Vite](https://vitejs.dev) | ~~`vite.config.ts`~~ | Використовуйте ключ [`vite`](/docs/api/configuration/nuxt-config#vite) у `nuxt.config`
| [webpack](https://webpack.js.org/) | ~~`webpack.config.ts`~~ | Використовуйте ключ [`webpack`](/docs/api/configuration/nuxt-config#webpack-1) У `nuxt.config`

Here is a list of other common config files:
Ось список інших загальних файлів налаштувань:

Name | Config File | How To Configure
Назва | Кофігураційний Файл | Як Налаштувати
|---------------------------------------------|-------------------------|--------------------------
| [TypeScript](https://www.typescriptlang.org) | `tsconfig.json` | [More Info](/docs/guide/concepts/typescript#nuxttsconfigjson)
| [ESLint](https://eslint.org) | `.eslintrc.js` | [More Info](https://eslint.org/docs/latest/user-guide/configuring/configuration-files)
| [Prettier](https://prettier.io) | `.prettierrc.json` | [More Info](https://prettier.io/docs/en/configuration.html)
| [Stylelint](https://stylelint.io) | `.stylelintrc.json` | [More Info](https://stylelint.io/user-guide/configure)
| [TailwindCSS](https://tailwindcss.com) | `tailwind.config.js` | [More Info](https://tailwindcss.nuxtjs.org/tailwind/config/)
| [Vitest](https://vitest.dev) | `vitest.config.ts` | [More Info](https://vitest.dev/config/)
| [TypeScript](https://www.typescriptlang.org) | `tsconfig.json` | [Докладніше](/docs/guide/concepts/typescript#nuxttsconfigjson)
| [ESLint](https://eslint.org) | `.eslintrc.js` | [Докладніше](https://eslint.org/docs/latest/user-guide/configuring/configuration-files)
| [Prettier](https://prettier.io) | `.prettierrc.json` | [Докладніше](https://prettier.io/docs/en/configuration.html)
| [Stylelint](https://stylelint.io) | `.stylelintrc.json` | [Докладніше](https://stylelint.io/user-guide/configure)
| [TailwindCSS](https://tailwindcss.com) | `tailwind.config.js` | [Докладніше](https://tailwindcss.nuxtjs.org/tailwind/config/)
| [Vitest](https://vitest.dev) | `vitest.config.ts` | [Докладніше](https://vitest.dev/config/)