@nuxt/docs-nightly 5.0.0-29740135.daae2228 → 5.0.0-29740294.24eec37d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -107,6 +107,12 @@ deno run dev -o
|
|
|
107
107
|
Well done! A browser window should automatically open for <http://localhost:3000>.
|
|
108
108
|
::
|
|
109
109
|
|
|
110
|
+
::tip{icon="i-lucide-container"}
|
|
111
|
+
If you're using Docker or want a consistent development environment across machines, consider using a dev container.
|
|
112
|
+
|
|
113
|
+
[Learn more about dev containers](/docs/4.x/guide/best-practices/devcontainers)
|
|
114
|
+
::
|
|
115
|
+
|
|
110
116
|
::
|
|
111
117
|
|
|
112
118
|
## Next Steps
|
|
@@ -356,6 +356,25 @@ export default defineNuxtConfig({
|
|
|
356
356
|
Any nested directories need to be added first as they are scanned in order.
|
|
357
357
|
::
|
|
358
358
|
|
|
359
|
+
Each directory entry also accepts `pattern` and `ignore` glob options, which control which files are scanned within `path`. This is useful when your components live in nested folders that don't follow the default layout, such as a domain-driven structure:
|
|
360
|
+
|
|
361
|
+
```ts twoslash [nuxt.config.ts]
|
|
362
|
+
export default defineNuxtConfig({
|
|
363
|
+
components: [
|
|
364
|
+
// ~/domains/blog/components/PostCard.vue => <PostCard />
|
|
365
|
+
{
|
|
366
|
+
path: '~/domains',
|
|
367
|
+
pattern: '*/components/**',
|
|
368
|
+
pathPrefix: false,
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
})
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
::note
|
|
375
|
+
If `pattern` is specified, the `extensions` option has no effect, so make sure your pattern matches the file extensions you want to scan.
|
|
376
|
+
::
|
|
377
|
+
|
|
359
378
|
## npm Packages
|
|
360
379
|
|
|
361
380
|
If you want to auto-import components from an npm package, you can use [`addComponent`](/docs/4.x/api/kit/components#addcomponent) in a [local module](/docs/4.x/directory-structure/modules) to register them.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
navigation.title: 'Dev Containers'
|
|
3
|
+
title: Dev Containers
|
|
4
|
+
description: Set up or open a Nuxt project in a dev container for a consistent development environment.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Setting Up a Dev Container
|
|
8
|
+
|
|
9
|
+
If you're starting a new Nuxt project and want to develop inside a dev container, you can add the configuration yourself.
|
|
10
|
+
|
|
11
|
+
::read-more{to="https://code.visualstudio.com/docs/devcontainers/containers" target="_blank"}
|
|
12
|
+
Read more about dev containers
|
|
13
|
+
::
|
|
14
|
+
|
|
15
|
+
### Prerequisites
|
|
16
|
+
|
|
17
|
+
- [Visual Studio Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
|
|
18
|
+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) or [Docker Engine](https://docs.docker.com/engine/)
|
|
19
|
+
|
|
20
|
+
### Create the Configuration
|
|
21
|
+
|
|
22
|
+
Create a `.devcontainer/` folder in your project root with these two files:
|
|
23
|
+
|
|
24
|
+
```json [devcontainer.json]
|
|
25
|
+
{
|
|
26
|
+
"name": "nuxt-devcontainer",
|
|
27
|
+
"build": {
|
|
28
|
+
"dockerfile": "Dockerfile",
|
|
29
|
+
"context": "../"
|
|
30
|
+
},
|
|
31
|
+
"forwardPorts": [3000],
|
|
32
|
+
"portsAttributes": {
|
|
33
|
+
"3000": {
|
|
34
|
+
"label": "Application",
|
|
35
|
+
"onAutoForward": "openPreview"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"mounts": [
|
|
39
|
+
"type=volume,target=${containerWorkspaceFolder}/node_modules"
|
|
40
|
+
],
|
|
41
|
+
"postStartCommand": "pnpm install && pnpm dev:prepare"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```dockerfile [Dockerfile]
|
|
46
|
+
FROM node:lts
|
|
47
|
+
|
|
48
|
+
WORKDIR /app
|
|
49
|
+
|
|
50
|
+
RUN npm i -g corepack && corepack enable
|
|
51
|
+
|
|
52
|
+
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
53
|
+
RUN pnpm install --frozen-lockfile
|
|
54
|
+
|
|
55
|
+
COPY . .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This configuration uses Node.js LTS and enables pnpm via corepack. It forwards port 3000 for the Nuxt dev server and persists `node_modules` in a Docker volume to avoid reinstallation on container restarts.
|
|
59
|
+
|
|
60
|
+
::tip
|
|
61
|
+
To use a different package manager, replace `corepack enable` with your preferred manager (for example, `npm install -g yarn`) and update the `postStartCommand` accordingly.
|
|
62
|
+
::
|
|
63
|
+
|
|
64
|
+
## Opening an Existing Dev Container
|
|
65
|
+
|
|
66
|
+
If a project already includes a dev container configuration, you can open it using any of these methods:
|
|
67
|
+
|
|
68
|
+
### 1. VS Code Prompt
|
|
69
|
+
|
|
70
|
+
When you open the project in VS Code, you should see a notification in the bottom right corner:
|
|
71
|
+
|
|
72
|
+
> "Reopen in Dev Containers"
|
|
73
|
+
|
|
74
|
+
Click this button to build and open the project in a dev container.
|
|
75
|
+
|
|
76
|
+
### 2. Command Palette
|
|
77
|
+
|
|
78
|
+
If you dismiss the prompt or want to manually trigger it:
|
|
79
|
+
|
|
80
|
+
1. Open the Command Palette (`Cmd+Shift+P` on Mac, `Ctrl+Shift+P` on Windows/Linux)
|
|
81
|
+
2. Search for **"Dev Containers: Reopen in Container"**
|
|
82
|
+
3. Select it
|
|
83
|
+
|
|
84
|
+
VS Code will build the container and reopen your project.
|
|
85
|
+
|
|
86
|
+
### 3. Dev Containers CLI
|
|
87
|
+
|
|
88
|
+
For advanced users or CI workflows, you can use the Dev Containers CLI directly:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Install the CLI (if not already installed)
|
|
92
|
+
npm install -g @devcontainers/cli
|
|
93
|
+
|
|
94
|
+
# Build and open the project in a container
|
|
95
|
+
devcontainer up --workspace-folder .
|
|
96
|
+
|
|
97
|
+
# After making changes to .devcontainer, rebuild
|
|
98
|
+
devcontainer build
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Next Steps
|
|
102
|
+
|
|
103
|
+
Once the container is running:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pnpm dev
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Your Nuxt app will be available at <http://localhost:3000>.
|