diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 68d3ffb9d6..411c41292b 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts +FROM node:lts@sha256:48db4f6ea21d134be744207225753a1730c4bc1b4cdf836d44511c36bf0e34d7 RUN apt-get update && \ apt-get install -fy libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdbus-1-3 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 && \ diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index ad059c3630..780ffed438 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,6 +1,6 @@ name: "\U0001F41E Bug report" description: Create a report to help us improve Nuxt -labels: ["pending triage", "3.x"] +labels: ["pending triage"] body: - type: markdown attributes: @@ -36,7 +36,7 @@ body: validations: required: true - type: textarea - id: additonal + id: additional attributes: label: Additional context description: If applicable, add any other context about the problem here diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ff8f4c2377..3527bf128b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,8 @@ blank_issues_enabled: true contact_links: - - name: ๐Ÿ“š Nuxt 3 Documentation + - name: ๐Ÿ“š Nuxt Documentation url: https://nuxt.com/docs - about: Check the documentation for usage of Nuxt 3 - - name: ๐Ÿ“š Nuxt 2 Documentation - url: https://v2.nuxt.com - about: Check the documentation for usage of Nuxt 2 + about: Check the documentation for usage of Nuxt - name: ๐Ÿ’ฌ Discussions url: https://github.com/nuxt/nuxt/discussions about: Use discussions if you have another issue, an idea for improvement or for asking questions. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index a5614e9304..b155f19563 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,6 +1,6 @@ name: "๐Ÿš€ Feature request" description: Suggest a feature that will improve Nuxt -labels: ["pending triage", "3.x"] +labels: ["pending triage"] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/z-bug-report-2.yml b/.github/ISSUE_TEMPLATE/z-bug-report-2.yml deleted file mode 100644 index d4124367b2..0000000000 --- a/.github/ISSUE_TEMPLATE/z-bug-report-2.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: "\U0001F41E Bug report (Nuxt 2)" -description: Create a report to help us improve Nuxt -labels: ["pending triage", "2.x"] -body: - - type: markdown - attributes: - value: | - Please carefully read the contribution docs before creating a bug report - ๐Ÿ‘‰ https://nuxt.com/docs/community/reporting-bugs - - Please use a template below to create a minimal reproduction - ๐Ÿ‘‰ https://stackblitz.com/github/nuxt/starter/tree/v2 - ๐Ÿ‘‰ https://codesandbox.io/s/github/nuxt/starter/v2 - - type: textarea - id: bug-env - attributes: - label: Environment - description: You can use `npx envinfo --system --npmPackages '{nuxt,@nuxt/*}' --binaries --browsers` to fill this section - placeholder: Environment - validations: - required: true - - type: textarea - id: reproduction - attributes: - label: Reproduction - description: Please provide a link to a repo that can reproduce the problem you ran into. A [**minimal reproduction**](https://nuxt.com/docs/community/reporting-bugs#create-a-minimal-reproduction) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided we might close it. - placeholder: Reproduction - validations: - required: true - - type: textarea - id: bug-description - attributes: - label: Describe the bug - description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! - placeholder: Bug description - validations: - required: true - - type: textarea - id: additonal - attributes: - label: Additional context - description: If applicable, add any other context about the problem here - - type: textarea - id: logs - attributes: - label: Logs - description: | - Optional if provided reproduction. Please try not to insert an image but copy paste the log text. - render: shell-script diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000000..1ab482ad65 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,10 @@ +paths: + - 'packages/*/dist/**' + - 'packages/nuxt/bin/**' + - 'packages/schema/schema/**' +paths-ignore: + - 'test/**' + - '**/*.test.js' + - '**/*.test.ts' + - '**/*.test.tsx' + - '**/__tests__/**' diff --git a/.github/workflows/autofix-docs.yml b/.github/workflows/autofix-docs.yml index edc59497ef..9410a7e3e0 100644 --- a/.github/workflows/autofix-docs.yml +++ b/.github/workflows/autofix-docs.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -27,7 +27,10 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build (stub) + run: pnpm dev:prepare + - name: Lint (docs) run: pnpm lint:docs:fix - - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 + - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 4af68cee5e..fbc7aaea90 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -52,4 +52,4 @@ jobs: - name: Lint (code) run: pnpm lint:fix - - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 + - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f3bc4aa393..9a8d3404b7 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -29,9 +29,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -46,7 +46,7 @@ jobs: run: pnpm build - name: Run benchmarks - uses: CodSpeedHQ/action@0b631f8998f2389eb5144632b6f9f8fabd33a86e # v2.4.1 + uses: CodSpeedHQ/action@ab07afd34cbbb7a1306e8d14b7cc44e029eee37a # v3.0.0 with: run: pnpm vitest bench token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/.github/workflows/cache-cleanup.yml b/.github/workflows/cache-cleanup.yml index b71b0e9baa..bda394c562 100644 --- a/.github/workflows/cache-cleanup.yml +++ b/.github/workflows/cache-cleanup.yml @@ -6,6 +6,8 @@ on: types: - closed +permissions: {} + jobs: cleanup: runs-on: ubuntu-latest @@ -20,14 +22,14 @@ jobs: gh extension install actions/gh-actions-cache echo "Fetching list of cache keys" - cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" -L 100 | cut -f 1 ) ## Setting this to not fail the workflow while deleting cache keys. set +e echo "Deleting caches..." for cacheKey in $cacheKeysForPR do - gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm done echo "Done" env: diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index b2e4b57ea5..97461ca364 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -4,11 +4,9 @@ on: push: branches: - main - - 2.x + - 3.x -permissions: - pull-requests: write - contents: write +permissions: {} concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.sha }} @@ -16,15 +14,19 @@ concurrency: jobs: update: - if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.') + if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.') && !contains(github.event.head_commit.message, 'v4.') runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 337bde8734..8070b3af64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,14 @@ on: - "*.md" branches: - main + - 3.x pull_request: paths-ignore: - "docs/**" - "*.md" branches: - main + - 3.x - "!v[0-9]*" # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml @@ -35,9 +37,9 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -55,7 +57,7 @@ jobs: run: pnpm build - name: Cache dist - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: retention-days: 3 name: dist @@ -68,36 +70,30 @@ jobs: actions: read contents: read security-events: write - needs: - - build steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 20 - cache: "pnpm" - - - name: Install dependencies - run: pnpm install + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Initialize CodeQL - uses: github/codeql-action/init@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/init@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 with: - languages: javascript + config: | + paths: + - 'packages/*/src/**' + - 'packages/nuxt/bin/**' + - 'packages/schema/schema/**' + paths-ignore: + - 'test/**' + - '**/*.spec.ts' + - '**/*.test.ts' + - '**/__snapshots__/**' + languages: javascript-typescript queries: +security-and-quality - - name: Restore dist cache - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 - with: - name: dist - path: packages - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/analyze@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 with: - category: "/language:javascript" + category: "/language:javascript-typescript" typecheck: runs-on: ${{ matrix.os }} @@ -111,9 +107,9 @@ jobs: module: ["bundler", "node"] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -122,7 +118,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages @@ -142,9 +138,9 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -166,9 +162,9 @@ jobs: needs: - build steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -198,7 +194,6 @@ jobs: builder: ["vite", "webpack"] context: ["async", "default"] manifest: ["manifest-on", "manifest-off"] - version: ["v4", "v3"] payload: ["json", "js"] node: [18] exclude: @@ -218,9 +213,9 @@ jobs: timeout-minutes: 15 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: ${{ matrix.node }} cache: "pnpm" @@ -232,7 +227,7 @@ jobs: run: pnpm playwright-core install chromium - name: Restore dist cache - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages @@ -244,16 +239,17 @@ jobs: TEST_BUILDER: ${{ matrix.builder }} TEST_MANIFEST: ${{ matrix.manifest }} TEST_CONTEXT: ${{ matrix.context }} - TEST_V4: ${{ matrix.version == 'v4' }} TEST_PAYLOAD: ${{ matrix.payload }} SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }} - - uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 + - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on' with: token: ${{ secrets.CODECOV_TOKEN }} build-release: + concurrency: + group: release permissions: id-token: write if: | @@ -270,11 +266,11 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -283,18 +279,20 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages - name: Release Edge - run: ./scripts/release-edge.sh + run: ./scripts/release-edge.sh ${{ github.ref == 'refs/heads/main' && 'latest' || '3x' }} env: NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} NPM_CONFIG_PROVENANCE: true release-pr: + concurrency: + group: release permissions: id-token: write pull-requests: write @@ -309,11 +307,11 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -322,7 +320,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 62daccd7f9..2aae50705f 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,6 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: 'Dependency Review' - uses: actions/dependency-review-action@0c155c5e8556a497adf53f2c18edabf945ed8e70 # v4.3.2 + uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/check-links.yml b/.github/workflows/docs-check-links.yml similarity index 84% rename from .github/workflows/check-links.yml rename to .github/workflows/docs-check-links.yml index 4a81648ec0..7faed49485 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/docs-check-links.yml @@ -1,4 +1,4 @@ -name: Check links with Lychee +name: docs on: pull_request: @@ -7,6 +7,7 @@ on: - "*.md" branches: - main + - 3.x # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs @@ -25,10 +26,10 @@ jobs: restore-keys: cache-lychee- # check links with Lychee - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Lychee link checker - uses: lycheeverse/lychee-action@25a231001d1723960a301b7d4c82884dc7ef857d # for v1.8.0 + uses: lycheeverse/lychee-action@5047c2a4052946424ce139fe111135f6d7c0fe0b # for v1.8.0 with: # arguments with file types to check args: >- diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index c4ad6fb3de..206d15e8d2 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -1,11 +1,11 @@ -name: Deploy docs +name: docs on: push: paths: - "docs/**" branches: - - main + - 3.x # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f2bdb9b4f1..e0ade3b78a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Docs +name: docs on: push: @@ -9,6 +9,7 @@ on: # autofix workflow will be triggered instead for PRs branches: - main + - 3.x - "!v[0-9]*" # Remove default permissions of GITHUB_TOKEN for security @@ -20,9 +21,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -30,6 +31,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build (stub) + run: pnpm dev:prepare + - name: Lint (docs) run: pnpm lint:docs diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml new file mode 100644 index 0000000000..ebc2e3921b --- /dev/null +++ b/.github/workflows/label-issue.yml @@ -0,0 +1,28 @@ +name: chore + +on: + issues: + types: + - opened + +permissions: + issues: write + +jobs: + add-issue-labels: + name: Add labels + runs-on: ubuntu-latest + if: github.repository == 'nuxt/nuxt' + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + // add 'pending triage' label if issue is created with no labels + if (context.payload.issue.labels.length === 0) { + github.rest.issues.addLabels({ + issue_number: context.payload.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['pending triage'] + }) + } diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml index 9d462f9f8c..e0469e757f 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -1,4 +1,4 @@ -name: Label PR +name: chore on: pull_request_target: @@ -6,6 +6,9 @@ on: - opened branches: - main + - 3.x + +permissions: {} jobs: add-pr-labels: diff --git a/.github/workflows/lint-sherif.yml b/.github/workflows/lint-sherif.yml new file mode 100644 index 0000000000..951062afdc --- /dev/null +++ b/.github/workflows/lint-sherif.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + paths: + - "**/package.json" + branches: + - main + - 3.x + pull_request: + paths: + - "**/package.json" + branches: + - main + - 3.x + - "!v[0-9]*" + +permissions: + contents: read + +jobs: + lint-monorepo: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - run: corepack enable + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + - name: Lint monorepo + run: pnpm sherif -r multiple-dependency-versions diff --git a/.github/workflows/introspect.yml b/.github/workflows/lint-workflows.yml similarity index 59% rename from .github/workflows/introspect.yml rename to .github/workflows/lint-workflows.yml index 06f7994104..41b57db609 100644 --- a/.github/workflows/introspect.yml +++ b/.github/workflows/lint-workflows.yml @@ -6,11 +6,13 @@ on: - ".github/workflows/**" branches: - main + - 3.x pull_request: paths: - ".github/workflows/**" branches: - main + - 3.x - "!v[0-9]*" permissions: @@ -21,9 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions - name: Check workflow files - run: | - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/590d3bd9dde0c91f7a66071d40eb84716526e5a6/scripts/download-actionlint.bash) 1.6.25 - ./actionlint -color -shellcheck="" + uses: docker://rhysd/actionlint:1.7.2@sha256:89d3f90f82781dee3c8724651129634b08cf2241bbd67fcd02a1c5198119fc5e + with: + args: -color diff --git a/.github/workflows/notify-nuxt-bridge.yml b/.github/workflows/notify-nuxt-bridge.yml index fa97b12b95..b1f67c0509 100644 --- a/.github/workflows/notify-nuxt-bridge.yml +++ b/.github/workflows/notify-nuxt-bridge.yml @@ -4,6 +4,9 @@ on: types: [closed] paths: - "packages/nuxt/src/app/composables/**" + +permissions: {} + jobs: notify: if: github.event.pull_request.merged == true diff --git a/.github/workflows/nuxt2-edge.yml b/.github/workflows/nuxt2-edge.yml deleted file mode 100644 index 0b12d5c635..0000000000 --- a/.github/workflows/nuxt2-edge.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: nuxt2-nightly - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' - -# https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml -env: - # 7 GiB by default on GitHub, setting to 6 GiB - # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - NODE_OPTIONS: --max-old-space-size=6144 - -permissions: - contents: read - -jobs: - nightly: - if: github.repository_owner == 'nuxt' - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - with: - ref: '2.x' - fetch-depth: 0 # All history - - name: fetch tags - run: git fetch --depth=1 origin "+refs/tags/*:refs/tags/*" - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - - name: install - run: yarn --check-files --frozen-lockfile --non-interactive - - name: lint - run: yarn test:lint - - name: audit - run: yarn run audit - - name: build - run: yarn test:fixtures -i - - name: lint app - run: yarn lint:app - - name: test types - run: yarn test:types - - name: test dev - run: yarn test:dev - - name: test unit - run: yarn test:unit - - name: test e2e - run: yarn test:e2e - - name: bump version - run: yarn lerna version --yes --no-changelog --no-git-tag-version --no-push --force-publish "*" --loglevel verbose - - name: build - run: PACKAGE_SUFFIX=edge yarn build - - name: publish - run: ./scripts/workspace-run npm publish -q - env: - NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} - NPM_CONFIG_PROVENANCE: true - diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 7c0bbc3a86..7d26f17b24 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -14,6 +14,8 @@ permissions: jobs: release-pr: if: github.repository == 'nuxt/nuxt' && github.event.issue.pull_request && github.event.comment.body == '/trigger release' + concurrency: + group: release permissions: id-token: write pull-requests: write @@ -29,13 +31,30 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - name: Get PR Info + id: pr + env: + PR_NUMBER: ${{ github.event.issue.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + COMMENT_AT: ${{ github.event.comment.created_at }} + run: | + pr="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/"${GH_REPO}"/pulls/"${PR_NUMBER}")" + head_sha="$(echo "$pr" | jq -r .head.sha)" + updated_at="$(echo "$pr" | jq -r .updated_at)" + + if [[ $(date -d "$updated_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then + exit 1 + fi + + echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: - ref: refs/pull/${{ github.event.issue.number }}/merge - fetch-depth: 0 + ref: ${{ steps.pr.outputs.head_sha }} + fetch-depth: 1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d975a363f3..870a8ce28e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,17 +11,19 @@ permissions: {} jobs: release: - if: github.repository == 'nuxt/nuxt' && startsWith(github.event.head_commit.message, 'v3.') + if: github.repository == 'nuxt/nuxt' && (startsWith(github.event.head_commit.message, 'v3.') || startsWith(github.event.head_commit.message, 'v4.')) + concurrency: + group: release permissions: id-token: write runs-on: ubuntu-latest timeout-minutes: 20 steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 registry-url: "https://registry.npmjs.org/" diff --git a/.github/workflows/reproduire.yml b/.github/workflows/reproduire.yml index b001dd9fca..4f02b2ce3a 100644 --- a/.github/workflows/reproduire.yml +++ b/.github/workflows/reproduire.yml @@ -1,4 +1,4 @@ -name: Reproduire +name: chore on: issues: types: [labeled] @@ -10,7 +10,7 @@ jobs: reproduire: runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: Hebilicious/reproduire@4b686ae9cbb72dad60f001d278b6e3b2ce40a9ac # v0.0.9-mp with: label: needs reproduction diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 1a0a7912d0..e3d14a0b6c 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -2,7 +2,7 @@ # by a third-party and are governed by separate terms of service, privacy # policy, and support documentation. -name: Scorecard supply-chain security +name: ossf on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection @@ -32,12 +32,12 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 with: results_file: results.sarif results_format: sarif @@ -59,7 +59,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 if: github.repository == 'nuxt/nuxt' && success() with: name: SARIF file @@ -68,7 +68,7 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@9fdb3e49720b44c48891d036bb502feb25684276 # v3.25.6 + uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 if: github.repository == 'nuxt/nuxt' && success() with: sarif_file: results.sarif diff --git a/.github/workflows/semantic-pull-requests.yml b/.github/workflows/semantic-pull-requests.yml index 3bf40386bf..e569c4acc3 100644 --- a/.github/workflows/semantic-pull-requests.yml +++ b/.github/workflows/semantic-pull-requests.yml @@ -1,4 +1,4 @@ -name: Semantic pull request +name: chore on: pull_request_target: @@ -7,12 +7,12 @@ on: - edited - synchronize -permissions: - contents: read +permissions: {} jobs: - main: + semantic-pr: permissions: + contents: read pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR if: github.repository == 'nuxt/nuxt' && !startsWith(github.head_ref, 'v') @@ -20,7 +20,7 @@ jobs: name: Semantic pull request steps: - name: Validate PR title - uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # v5.5.2 + uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 with: scopes: | kit diff --git a/.github/workflows/stackblitz-link.yml b/.github/workflows/stackblitz-link.yml new file mode 100644 index 0000000000..997a48e846 --- /dev/null +++ b/.github/workflows/stackblitz-link.yml @@ -0,0 +1,17 @@ +name: chore +on: + issues: + types: + opened + +permissions: + issues: write + +jobs: + stackblitz: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: huang-julien/reproduire-sur-stackblitz@9ceccbfbb0f2f9a9a8db2d1f0dd909cf5cfe67aa # v1.0.2 + with: + reproduction-heading: '### Reproduction' diff --git a/.github/workflows/reproduire-close.yml b/.github/workflows/stale.yml similarity index 96% rename from .github/workflows/reproduire-close.yml rename to .github/workflows/stale.yml index cf72e9e0e0..23dccb624d 100644 --- a/.github/workflows/reproduire-close.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: Close incomplete issues +name: chore on: workflow_dispatch: schedule: diff --git a/.npmrc b/.npmrc index 8fb0b90fee..a1ecadcefc 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,4 @@ -shamefully-hoist=true +# TODO: consider resolving webpack loaders to absolute path +public-hoist-pattern[]=*-loader +public-hoist-pattern[]=webpack-* shell-emulator=true diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..fc78d099a7 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @danielroe diff --git a/README.md b/README.md index 9570d902ed..5c5e76cc4c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

Version Downloads - License + License Website Discord

@@ -34,7 +34,7 @@ It provides a number of features that make it easy to build fast, SEO-friendly, - ๐Ÿ  [Local Development](#local-development) - โ›ฐ๏ธ [Nuxt 2](#nuxt-2) - ๐Ÿ›Ÿ [Professional Support](#professional-support) -- ๐Ÿ”— [Follow us](#follow-us) +- ๐Ÿ”— [Follow Us](#follow-us) - โš–๏ธ [License](#license) --- @@ -101,23 +101,17 @@ Here are a few ways you can get involved: Follow the docs to [Set Up Your Local Development Environment](https://nuxt.com/docs/community/framework-contribution#setup) to contribute to the framework and documentation. -## โ›ฐ๏ธ Nuxt 2 - -You can find the code for Nuxt 2 on the [`2.x` branch](https://github.com/nuxt/nuxt/tree/2.x) and the documentation at [v2.nuxt.com](https://v2.nuxt.com). - -If you expect to be using Nuxt 2 beyond the EOL (End of Life) date (June 30, 2024), and still need a maintained version that can satisfy security and browser compatibility requirements, make sure to check out [HeroDevsโ€™ NES (Never-Ending Support) Nuxt 2](https://www.herodevs.com/support/nuxt-nes?utm_source=nuxt-github&utm_medium=nuxt-readme). - ## ๐Ÿ›Ÿ Professional Support - Technical audit & consulting: [Nuxt Experts](https://nuxt.com/enterprise/support) - Custom development & more: [Nuxt Agencies Partners](https://nuxt.com/enterprise/agencies) -## ๐Ÿ”— Follow us +## ๐Ÿ”— Follow Us

- Discord  Twitter  GitHub + Discord  Twitter  GitHub

## โš–๏ธ License -[MIT](./LICENSE) +[MIT](https://github.com/nuxt/nuxt/tree/main/LICENSE) diff --git a/docs/1.getting-started/1.introduction.md b/docs/1.getting-started/1.introduction.md index 47bfdb0bc4..90f7e84da0 100644 --- a/docs/1.getting-started/1.introduction.md +++ b/docs/1.getting-started/1.introduction.md @@ -1,7 +1,8 @@ --- -title: 'Introduction' +title: Introduction description: Nuxt's goal is to make web development intuitive and performant with a great Developer Experience in mind. -navigation.icon: i-ph-info-duotone +navigation: + icon: i-ph-info --- Nuxt is a free and [open-source framework](https://github.com/nuxt/nuxt) with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with [Vue.js](https://vuejs.org). @@ -76,7 +77,5 @@ Nuxt is composed of different [core packages](https://github.com/nuxt/nuxt/tree/ - Command line interface: [nuxi](https://github.com/nuxt/nuxt/tree/main/packages/nuxi) - Server engine: [nitro](https://github.com/unjs/nitro) - Development kit: [@nuxt/kit](https://github.com/nuxt/nuxt/tree/main/packages/kit) -- Nuxt 2 Bridge: [@nuxt/bridge](https://github.com/nuxt/bridge) We recommend reading each concept to have a full vision of Nuxt capabilities and the scope of each package. - diff --git a/docs/1.getting-started/10.deployment.md b/docs/1.getting-started/10.deployment.md index f381d6ca62..5b17574f89 100644 --- a/docs/1.getting-started/10.deployment.md +++ b/docs/1.getting-started/10.deployment.md @@ -1,7 +1,7 @@ --- title: 'Deployment' description: Learn how to deploy your Nuxt application to any hosting provider. -navigation.icon: i-ph-cloud-duotone +navigation.icon: i-ph-cloud --- A Nuxt application can be deployed on a Node.js server, pre-rendered for static hosting, or deployed to serverless or edge (CDN) environments. @@ -71,62 +71,7 @@ There are two ways to deploy a Nuxt application to any static hosting services: - Static site generation (SSG) with `ssr: true` pre-renders routes of your application at build time. (This is the default behavior when running `nuxi generate`.) It will also generate `/200.html` and `/404.html` single-page app fallback pages, which can render dynamic routes or 404 errors on the client (though you may need to configure this on your static host). - Alternatively, you can prerender your site with `ssr: false` (static single-page app). This will produce HTML pages with an empty `
` where your Vue app would normally be rendered. You will lose many SEO benefits of prerendering your site, so it is suggested instead to use [``](/docs/api/components/client-only) to wrap the portions of your site that cannot be server rendered (if any). -### Crawl-based Pre-rendering - -Use the [`nuxi generate` command](/docs/api/commands/generate) to build and pre-render your application using the [Nitro](/docs/guide/concepts/server-engine) crawler. This command is similar to `nuxt build` with the `nitro.static` option set to `true`, or running `nuxt build --prerender`. - -```bash [Terminal] -npx nuxi generate -``` - -That's it! You can now deploy the `.output/public` directory to any static hosting service or preview it locally with `npx serve .output/public`. - -Working of the Nitro crawler: - -1. Load the HTML of your application's root route (`/`), any non-dynamic pages in your `~/pages` directory, and any other routes in the `nitro.prerender.routes` array. -2. Save the HTML and `payload.json` to the `~/.output/public/` directory to be served statically. -3. Find all anchor tags (``) in the HTML to navigate to other routes. -4. Repeat steps 1-3 for each anchor tag found until there are no more anchor tags to crawl. - -This is important to understand since pages that are not linked to a discoverable page can't be pre-rendered automatically. - -::read-more{to="/docs/api/commands/generate#nuxi-generate"} -Read more about the `nuxi generate` command. -:: - -### Selective Pre-rendering - -You can manually specify routes that [Nitro](/docs/guide/concepts/server-engine) will fetch and pre-render during the build or ignore routes that you don't want to pre-render like `/dynamic` in the `nuxt.config` file: - -```ts twoslash [nuxt.config.ts] -export default defineNuxtConfig({ - nitro: { - prerender: { - routes: ['/user/1', '/user/2'], - ignore: ['/dynamic'] - } - } -}) -``` - -You can combine this with the `crawlLinks` option to pre-render a set of routes that the crawler can't discover like your `/sitemap.xml` or `/robots.txt`: - -```ts twoslash [nuxt.config.ts] -export default defineNuxtConfig({ - nitro: { - prerender: { - crawlLinks: true, - routes: ['/sitemap.xml', '/robots.txt'] - } - } -}) -``` - -Setting `nitro.prerender` to `true` is similar to `nitro.prerender.crawlLinks` to `true`. - -::read-more{to="https://nitro.unjs.io/config#prerender"} -Read more about pre-rendering in the Nitro documentation. -:: +:read-more{title="Nuxt prerendering" to="/docs/getting-started/prerendering"} ### Client-side Only Rendering @@ -140,13 +85,13 @@ export default defineNuxtConfig({ ## Hosting Providers -Nuxt 3 can be deployed to several cloud providers with a minimal amount of configuration: +Nuxt can be deployed to several cloud providers with a minimal amount of configuration: :read-more{to="/deploy"} ## Presets -In addition to Node.js servers and static hosting services, a Nuxt 3 project can be deployed with several well-tested presets and minimal amount of configuration. +In addition to Node.js servers and static hosting services, a Nuxt project can be deployed with several well-tested presets and minimal amount of configuration. You can explicitly set the desired preset in the [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) file: @@ -172,10 +117,13 @@ In most cases, Nuxt can work with third-party content that is not generated or c Accordingly, you should make sure that the following options are unchecked / disabled in Cloudflare. Otherwise, unnecessary re-rendering or hydration errors could impact your production application. -1. Speed > Optimization > Auto Minify: Uncheck JavaScript, CSS and HTML -2. Speed > Optimization > Disable "Rocket Loaderโ„ข" -3. Speed > Optimization > Disable "Mirage" +1. Speed > Optimization > Content Optimization > Auto Minify: Uncheck JavaScript, CSS and HTML +2. Speed > Optimization > Content Optimization > Disable "Rocket Loaderโ„ข" +3. Speed > Optimization > Image Optimization > Disable "Mirage" 4. Scrape Shield > Disable "Email Address Obfuscation" -5. Scrape Shield > Disable "Server-side Excludes" With these settings, you can be sure that Cloudflare won't inject scripts into your Nuxt application that may cause unwanted side effects. + +::tip +Their location on the Cloudflare dashboard sometimes changes so don't hesitate to look around. +:: diff --git a/docs/1.getting-started/11.testing.md b/docs/1.getting-started/11.testing.md index 9ae5b6264c..dce433a768 100644 --- a/docs/1.getting-started/11.testing.md +++ b/docs/1.getting-started/11.testing.md @@ -1,7 +1,7 @@ --- title: Testing description: How to test your Nuxt application. -navigation.icon: i-ph-check-circle-duotone +navigation.icon: i-ph-check-circle --- ::tip @@ -10,7 +10,7 @@ If you are a module author, you can find more specific information in the [Modul Nuxt offers first-class support for end-to-end and unit testing of your Nuxt application via `@nuxt/test-utils`, a library of test utilities and configuration that currently powers the [tests we use on Nuxt itself](https://github.com/nuxt/nuxt/tree/main/test) and tests throughout the module ecosystem. -::tip{icon="i-ph-video-duotone" to="https://www.youtube.com/watch?v=yGzwk9xi9gU" target="_blank"} +::tip{icon="i-ph-video" to="https://www.youtube.com/watch?v=yGzwk9xi9gU" target="_blank"} Watch a video from Alexander Lichter about getting started with the `@nuxt/test-utils`. :: @@ -22,13 +22,13 @@ In order to allow you to manage your other testing dependencies, `@nuxt/test-uti - you can choose between `vitest`, `cucumber`, `jest` and `playwright` for end-to-end test runners - `playwright-core` is only required if you wish to use the built-in browser testing utilities (and are not using `@playwright/test` as your test runner) -::code-group -```bash [yarn] -yarn add --dev @nuxt/test-utils vitest @vue/test-utils happy-dom playwright-core -``` +::package-managers ```bash [npm] npm i --save-dev @nuxt/test-utils vitest @vue/test-utils happy-dom playwright-core ``` +```bash [yarn] +yarn add --dev @nuxt/test-utils vitest @vue/test-utils happy-dom playwright-core +``` ```bash [pnpm] pnpm add -D @nuxt/test-utils vitest @vue/test-utils happy-dom playwright-core ``` @@ -161,7 +161,13 @@ export default defineVitestConfig({ #### `mountSuspended` -`mountSuspended` allows you to mount any Vue component within the Nuxt environment, allowing async setup and access to injections from your Nuxt plugins. For example: +`mountSuspended` allows you to mount any Vue component within the Nuxt environment, allowing async setup and access to injections from your Nuxt plugins. + +::alert{type=info} +Under the hood, `mountSuspended` wraps `mount` from `@vue/test-utils`, so you can check out [the Vue Test Utils documentation](https://test-utils.vuejs.org/guide/) for more on the options you can pass, and how to use this utility. +:: + +For example: ```ts twoslash import { it, expect } from 'vitest' @@ -207,6 +213,7 @@ it('can also mount an app', async () => { `renderSuspended` allows you to render any Vue component within the Nuxt environment using `@testing-library/vue`, allowing async setup and access to injections from your Nuxt plugins. This should be used together with utilities from Testing Library, e.g. `screen` and `fireEvent`. Install [@testing-library/vue](https://testing-library.com/docs/vue-testing-library/intro) in your project to use these. + Additionally, Testing Library also relies on testing globals for cleanup. You should turn these on in your [Vitest config](https://vitest.dev/config/#globals). The passed in component will be rendered inside a `
`. @@ -266,7 +273,9 @@ mockNuxtImport('useStorage', () => { // your tests here ``` -> **Note**: `mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [here](https://vitest.dev/api/vi.html#vi-mock). +::alert{type=info} +`mockNuxtImport` can only be used once per mocked import per test file. It is actually a macro that gets transformed to `vi.mock` and `vi.mock` is hoisted, as described [here](https://vitest.dev/api/vi.html#vi-mock). +:: If you need to mock a Nuxt import and provide different implementations between tests, you can do it by creating and exposing your mocks using [`vi.hoisted`](https://vitest.dev/api/vi.html#vi-hoisted), and then use those mocks in `mockNuxtImport`. You then have access to the mocked imports, and can change the implementation between tests. Be careful to [restore mocks](https://vitest.dev/api/mock.html#mockrestore) before or after each test to undo mock state changes between runs. @@ -412,18 +421,18 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and 1. Install the needed dependencies - ::code-group - ```bash [yarn] - yarn add --dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue - ``` + ::package-managers ```bash [npm] - npm i --save-dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue + npm i --save-dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue + ``` + ```bash [yarn] + yarn add --dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue ``` ```bash [pnpm] - pnpm add -D vitest @vue/test-utils happy-dom @vitejs/plugin-vue + pnpm add -D vitest @vue/test-utils happy-dom @vitejs/plugin-vue ``` ```bash [bun] - bun add --dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue + bun add --dev vitest @vue/test-utils happy-dom @vitejs/plugin-vue ``` :: @@ -432,7 +441,7 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and ```ts twoslash import { defineConfig } from 'vitest/config' import vue from '@vitejs/plugin-vue' - + export default defineConfig({ plugins: [vue()], test: { @@ -465,9 +474,9 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and ```ts twoslash import { describe, it, expect } from 'vitest' import { mount } from '@vue/test-utils' - + import HelloWorld from './HelloWorld.vue' - + describe('HelloWorld', () => { it('component renders Hello world properly', () => { const wrapper = mount(HelloWorld) @@ -478,13 +487,13 @@ If you prefer to use `@vue/test-utils` on its own for unit testing in Nuxt, and 6. Run vitest command - ::code-group - ```bash [yarn] - yarn test - ``` + ::package-managers ```bash [npm] npm run test ``` + ```bash [yarn] + yarn test + ``` ```bash [pnpm] pnpm run test ``` @@ -544,17 +553,22 @@ Please use the options below for the `setup` method. #### Features +- `build`: Whether to run a separate build step. + - Type: `boolean` + - Default: `true` (`false` if `browser` or `server` is disabled, or if a `host` is provided) + - `server`: Whether to launch a server to respond to requests in the test suite. - Type: `boolean` - - Default: `true` + - Default: `true` (`false` if a `host` is provided) - `port`: If provided, set the launched test server port to the value. - Type: `number | undefined` - Default: `undefined` -- `build`: Whether to run a separate build step. - - Type: `boolean` - - Default: `true` (`false` if `browser` or `server` is disabled) +- `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](#target-host-end-to-end-example). + - Type: `string` + - Default: `undefined` + - `browser`: Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite. - Type: `boolean` - Default: `false` @@ -566,6 +580,31 @@ Please use the options below for the `setup` method. - Type: `'vitest' | 'jest' | 'cucumber'` - Default: `'vitest'` +##### Target `host` end-to-end example + +A common use-case for end-to-end testing is running the tests against a deployed application running in the same environment typically used for Production. + +For local development or automated deploy pipelines, testing against a separate local server can be more efficient and is typically faster than allowing the test framework to rebuild between tests. + +To utilize a separate target host for end-to-end tests, simply provide the `host` property of the `setup` function with the desired URL. + +```ts +import { setup, createPage } from '@nuxt/test-utils/e2e' +import { describe, it, expect } from 'vitest' + +describe('login page', async () => { + await setup({ + host: 'http://localhost:8787', + }) + + it('displays the email and password fields', async () => { + const page = await createPage('/login') + expect(await page.getByTestId('email').isVisible()).toBe(true) + expect(await page.getByTestId('password').isVisible()).toBe(true) + }) +}) +``` + ### APIs #### `$fetch(url)` @@ -619,13 +658,13 @@ const page = await createPage('/page') We also provide first-class support for testing Nuxt within [the Playwright test runner](https://playwright.dev/docs/intro). -::code-group -```bash [yarn] -yarn add --dev @playwright/test @nuxt/test-utils -``` +::package-managers ```bash [npm] npm i --save-dev @playwright/test @nuxt/test-utils ``` +```bash [yarn] +yarn add --dev @playwright/test @nuxt/test-utils +``` ```bash [pnpm] pnpm add -D @playwright/test @nuxt/test-utils ``` diff --git a/docs/1.getting-started/12.upgrade.md b/docs/1.getting-started/12.upgrade.md index c8e6c66ef0..760bb6ab1e 100644 --- a/docs/1.getting-started/12.upgrade.md +++ b/docs/1.getting-started/12.upgrade.md @@ -1,7 +1,7 @@ --- title: Upgrade Guide description: 'Learn how to upgrade to the latest Nuxt version.' -navigation.icon: i-ph-arrow-circle-up-duotone +navigation.icon: i-ph-arrow-circle-up --- @@ -11,27 +11,49 @@ navigation.icon: i-ph-arrow-circle-up-duotone To upgrade Nuxt to the [latest release](https://github.com/nuxt/nuxt/releases), use the `nuxi upgrade` command. -```bash [Terminal] +::package-managers + +```bash [npm] npx nuxi upgrade ``` +```bash [yarn] +yarn dlx nuxi upgrade +``` + +```bash [pnpm] +pnpm dlx nuxi upgrade +``` + +```bash [bun] +bun x nuxi upgrade +``` + +:: + ### Nightly Release Channel To use the latest Nuxt build and test features before their release, read about the [nightly release channel](/docs/guide/going-further/nightly-release-channel) guide. +::alert{type="warning"} +The nightly release channel `latest` tag is currently tracking the Nuxt v4 branch, meaning that it is particularly likely to have breaking changes right now - be careful! + +You can opt in to the 3.x branch nightly releases with `"nuxt": "npm:nuxt-nightly@3x"`. +:: + ## Testing Nuxt 4 Nuxt 4 is planned to be released **on or before June 14** (though obviously this is dependent on having enough time after Nitro's major release to be properly tested in the community, so be aware that this is not an exact date). -Until then, it is possible to test many of Nuxt 4's breaking changes on the nightly release channel. +Until then, it is possible to test many of Nuxt 4's breaking changes from Nuxt version 3.12+. -::tip{icon="i-ph-video-duotone" to="https://www.youtube.com/watch?v=r4wFKlcJK6c" target="_blank"} +::tip{icon="i-ph-video" to="https://www.youtube.com/watch?v=r4wFKlcJK6c" target="_blank"} Watch a video from Alexander Lichter showing how to opt in to Nuxt 4's breaking changes already. :: ### Opting in to Nuxt 4 -First, opt in to the nightly release channel [following these steps](/docs/guide/going-further/nightly-release-channel#opting-in). +First, upgrade Nuxt to the [latest release](https://github.com/nuxt/nuxt/releases). Then you can set your `compatibilityVersion` to match Nuxt 4 behavior: @@ -75,6 +97,24 @@ Breaking or significant changes will be noted here along with migration steps fo This section is subject to change until the final release, so please check back here regularly if you are testing Nuxt 4 using `compatibilityVersion: 4`. :: +#### Migrating Using Codemods + +To facilitate the upgrade process, we have collaborated with the [Codemod](https://github.com/codemod-com/codemod) team to automate many migration steps with some open-source codemods. + +::note +If you encounter any issues, please report them to the Codemod team with `npx codemod feedback` ๐Ÿ™ +:: + +For a complete list of Nuxt 4 codemods, detailed information on each, their source, and various ways to run them, visit the [Codemod Registry](https://go.codemod.com/codemod-registry). + +You can run all the codemods mentioned in this guide using the following `codemod` recipe: + +```bash +npx codemod@latest nuxt/4/migration-recipe +``` + +This command will execute all codemods in sequence, with the option to deselect any that you do not wish to run. Each codemod is also listed below alongside its respective change and can be executed independently. + #### New Directory Structure ๐Ÿšฆ **Impact Level**: Significant @@ -87,7 +127,8 @@ Nuxt now defaults to a new directory structure, with backwards compatibility (so * the new Nuxt default `srcDir` is `app/` by default, and most things are resolved from there. * `serverDir` now defaults to `/server` rather than `/server` -* `modules` and `public` are resolved relative to `` by default +* `layers/`, `modules/` and `public/` are resolved relative to `` by default +* if using [Nuxt Content v2.13+](https://github.com/nuxt/content/pull/2649), `content/` is resolved relative to `` * a new `dir.app` is added, which is the directory we look for `router.options.ts` and `spa-loading-template.html` - this defaults to `/`
@@ -109,6 +150,8 @@ app/ app.config.ts app.vue router.options.ts +content/ +layers/ modules/ node_modules/ public/ @@ -134,9 +177,15 @@ nuxt.config.ts 1. Create a new directory called `app/`. 1. Move your `assets/`, `components/`, `composables/`, `layouts/`, `middleware/`, `pages/`, `plugins/` and `utils/` folders under it, as well as `app.vue`, `error.vue`, `app.config.ts`. If you have an `app/router-options.ts` or `app/spa-loading-template.html`, these paths remain the same. -1. Make sure your `nuxt.config.ts`, `modules/`, `public/` and `server/` folders remain outside the `app/` folder, in the root of your project. +1. Make sure your `nuxt.config.ts`, `content/`, `layers/`, `modules/`, `public/` and `server/` folders remain outside the `app/` folder, in the root of your project. -However, migration is _not required_. If you wish to keep your current folder structure, Nuxt should auto-detect it. (If it does not, please raise an issue.) You can also force a v3 folder structure with the following configuration: +::tip +You can automate this migration by running `npx codemod@latest nuxt/4/file-structure` +:: + +However, migration is _not required_. If you wish to keep your current folder structure, Nuxt should auto-detect it. (If it does not, please raise an issue.) The one exception is that if you _already_ have a custom `srcDir`. In this case, you should be aware that your `modules/`, `public/` and `server/` folders will be resolved from your `rootDir` rather than from your custom `srcDir`. You can override this by configuring `dir.modules`, `dir.public` and `serverDir` if you need to. + +You can also force a v3 folder structure with the following configuration: ```ts [nuxt.config.ts] export default defineNuxtConfig({ @@ -204,9 +253,16 @@ Previously `data` was initialized to `null` but reset in `clearNuxtData` to `und ##### Migration Steps +If you were checking if `data.value` or `error.value` were `null`, you can update these checks to check for `undefined` instead. + +::tip +You can automate this step by running `npx codemod@latest nuxt/4/default-data-error-value` +:: + If you encounter any issues you can revert back to the previous behavior with: ```ts twoslash [nuxt.config.ts] +// @errors: 2353 export default defineNuxtConfig({ experimental: { defaults: { @@ -221,6 +277,51 @@ export default defineNuxtConfig({ Please report an issue if you are doing this, as we do not plan to keep this as configurable. +#### Removal of deprecated `boolean` values for `dedupe` option when calling `refresh` in `useAsyncData` and `useFetch` + +๐Ÿšฆ **Impact Level**: Minimal + +##### What Changed + +Previously it was possible to pass `dedupe: boolean` to `refresh`. These were aliases of `cancel` (`true`) and `defer` (`false`). + +```ts twoslash [app.vue] +// @errors: 2322 +const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt 3!' })) + +async function refreshData () { + await refresh({ dedupe: true }) +} +``` + +##### Reasons for Change + +These aliases were removed, for greater clarity. + +The issue came up when adding `dedupe` as an option to `useAsyncData`, and we removed the boolean values as they ended up being _opposites_. + +`refresh({ dedupe: false })` meant 'do not _cancel_ existing requests in favour of this new one'. But passing `dedupe: true` within the options of `useAsyncData` means 'do not make any new requests if there is an existing pending request.' (See [PR](https://github.com/nuxt/nuxt/pull/24564#pullrequestreview-1764584361).) + +##### Migration Steps + +The migration should be straightforward: + +```diff + const { refresh } = await useAsyncData(async () => ({ message: 'Hello, Nuxt 3!' })) + + async function refreshData () { +- await refresh({ dedupe: true }) ++ await refresh({ dedupe: 'cancel' }) + +- await refresh({ dedupe: false }) ++ await refresh({ dedupe: 'defer' }) + } +``` + +::tip +You can automate this step by running `npx codemod@latest nuxt/4/deprecated-dedupe-value` +:: + #### Respect defaults when clearing `data` in `useAsyncData` and `useFetch` ๐Ÿšฆ **Impact Level**: Minimal @@ -238,6 +339,7 @@ Often users set an appropriately empty value, such as an empty array, to avoid t If you encounter any issues you can revert back to the previous behavior, for now, with: ```ts twoslash [nuxt.config.ts] +// @errors: 2353 export default defineNuxtConfig({ experimental: { resetAsyncDataToUndefined: true, @@ -283,6 +385,10 @@ In most cases, no migration steps are required, but if you rely on the reactivit }) ``` +::tip +If you need to, you can automate this step by running `npx codemod@latest nuxt/4/shallow-function-reactivity` +:: + #### Absolute Watch Paths in `builder:watch` ๐Ÿšฆ **Impact Level**: Minimal @@ -310,6 +416,29 @@ However, if you are a module author using the `builder:watch` hook and wishing t }) ``` +::tip +You can automate this step by running `npx codemod@latest nuxt/4/absolute-watch-path` +:: + +#### Removal of `window.__NUXT__` object + +##### What Changed + +We are removing the global `window.__NUXT__` object after the app finishes hydration. + +##### Reasons for Change + +This opens the way to multi-app patterns ([#21635](https://github.com/nuxt/nuxt/issues/21635)) and enables us to focus on a single way to access Nuxt app data - `useNuxtApp()`. + +##### Migration Steps + +The data is still available, but can be accessed with `useNuxtApp().payload`: + +```diff +- console.log(window.__NUXT__) ++ console.log(useNuxtApp().payload) +``` + #### Directory index scanning ๐Ÿšฆ **Impact Level**: Medium @@ -398,6 +527,10 @@ const importSources = (sources: string | string[], { lazy = false } = {}) => { const importName = genSafeVariableName ``` +::tip +You can automate this step by running `npx codemod@latest nuxt/4/template-compilation-changes` +:: + #### Removal of Experimental Features ๐Ÿšฆ **Impact Level**: Minimal @@ -406,10 +539,11 @@ const importName = genSafeVariableName Four experimental features are no longer configurable in Nuxt 4: -* `treeshakeClientOnly` will be `true` (default since v3.0) -* `configSchema` will be `true` (default since v3.3) -* `polyfillVueUseHead` will be `false` (default since v3.4) -* `respectNoSSRHeader` will be `false` (default since v3.4) +* `experimental.treeshakeClientOnly` will be `true` (default since v3.0) +* `experimental.configSchema` will be `true` (default since v3.3) +* `experimental.polyfillVueUseHead` will be `false` (default since v3.4) +* `experimental.respectNoSSRHeader` will be `false` (default since v3.4) +* `vite.devBundler` is no longer configurable - it will use `vite-node` by default ##### Reasons for Change @@ -421,11 +555,11 @@ These options have been set to their current values for some time and we do not * `respectNoSSRHeader`is implementable in user-land with [server middleware](https://github.com/nuxt/nuxt/blob/c660b39447f0d5b8790c0826092638d321cd6821/packages/nuxt/src/core/runtime/nitro/no-ssr.ts#L8-L9) -## Nuxt 2 vs Nuxt 3 +## Nuxt 2 vs Nuxt 3+ In the table below, there is a quick comparison between 3 versions of Nuxt: -Feature / Version | Nuxt 2 | Nuxt Bridge | Nuxt 3 +Feature / Version | Nuxt 2 | Nuxt Bridge | Nuxt 3+ -------------------------|-----------------|------------------|--------- Vue | 2 | 2 | 3 Stability | ๐Ÿ˜Š Stable | ๐Ÿ˜Š Stable | ๐Ÿ˜Š Stable @@ -443,9 +577,9 @@ Vite | โš ๏ธ Partial | ๐Ÿšง Partial | โœ… Nuxi CLI | โŒ Old | โœ… nuxi | โœ… nuxi Static sites | โœ… | โœ… | โœ… -## Nuxt 2 to Nuxt 3 +## Nuxt 2 to Nuxt 3+ -The migration guide provides a step-by-step comparison of Nuxt 2 features to Nuxt 3 features and guidance to adapt your current application. +The migration guide provides a step-by-step comparison of Nuxt 2 features to Nuxt 3+ features and guidance to adapt your current application. ::read-more{to="/docs/migration/overview"} Check out the **guide to migrating from Nuxt 2 to Nuxt 3**. @@ -453,7 +587,7 @@ Check out the **guide to migrating from Nuxt 2 to Nuxt 3**. ## Nuxt 2 to Nuxt Bridge -If you prefer to progressively migrate your Nuxt 2 application to Nuxt 3, you can use Nuxt Bridge. Nuxt Bridge is a compatibility layer that allows you to use Nuxt 3 features in Nuxt 2 with an opt-in mechanism. +If you prefer to progressively migrate your Nuxt 2 application to Nuxt 3, you can use Nuxt Bridge. Nuxt Bridge is a compatibility layer that allows you to use Nuxt 3+ features in Nuxt 2 with an opt-in mechanism. ::read-more{to="/docs/bridge/overview"} **Migrate from Nuxt 2 to Nuxt Bridge** diff --git a/docs/1.getting-started/2.installation.md b/docs/1.getting-started/2.installation.md index 1af58ad887..128a135f57 100644 --- a/docs/1.getting-started/2.installation.md +++ b/docs/1.getting-started/2.installation.md @@ -1,7 +1,7 @@ --- title: 'Installation' description: 'Get started with Nuxt quickly with our online starters or start locally with your terminal.' -navigation.icon: i-ph-play-duotone +navigation.icon: i-ph-play --- ## Play Online @@ -35,18 +35,22 @@ Or follow the steps below to set up a new Nuxt project on your computer. Open a terminal (if you're using [Visual Studio Code](https://code.visualstudio.com), you can open an [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal)) and use the following command to create a new starter project: -::code-group +::package-managers -```bash [npx] +```bash [npm] npx nuxi@latest init ``` +```bash [yarn] +yarn dlx nuxi@latest init +``` + ```bash [pnpm] pnpm dlx nuxi@latest init ``` ```bash [bun] -bunx nuxi@latest init +bun x nuxi@latest init ``` :: @@ -71,16 +75,16 @@ cd Now you'll be able to start your Nuxt app in development mode: -::code-group - -```bash [yarn] -yarn dev --open -``` +::package-managers ```bash [npm] npm run dev -- -o ``` +```bash [yarn] +yarn dev --open +``` + ```bash [pnpm] pnpm dev -o ``` @@ -90,12 +94,12 @@ bun run dev -o ``` :: -::tip{icon="i-ph-check-circle-duotone"} +::tip{icon="i-ph-check-circle"} Well done! A browser window should automatically open for . :: ## Next Steps -Now that you've created your Nuxt 3 project, you are ready to start building your application. +Now that you've created your Nuxt project, you are ready to start building your application. :read-more{title="Nuxt Concepts" to="/docs/guide/concepts"} diff --git a/docs/1.getting-started/3.configuration.md b/docs/1.getting-started/3.configuration.md index 49a0822ecb..866de735f5 100644 --- a/docs/1.getting-started/3.configuration.md +++ b/docs/1.getting-started/3.configuration.md @@ -1,7 +1,7 @@ --- title: Configuration description: Nuxt is configured with sensible defaults to make you productive. -navigation.icon: i-ph-gear-duotone +navigation.icon: i-ph-gear --- @@ -29,7 +29,7 @@ Every option is described in the **Configuration Reference**. 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. :: -### Environment overrides +### Environment Overrides You can configure fully typed, per-environment overrides in your nuxt.config @@ -46,7 +46,7 @@ export default defineNuxtConfig({ }) ``` -::tip{icon="i-ph-video-duotone" to="https://www.youtube.com/watch?v=DFZI2iVCrNc" target="_blank"} +::tip{icon="i-ph-video" to="https://www.youtube.com/watch?v=DFZI2iVCrNc" target="_blank"} Watch a video from Alexander Lichter about the env-aware `nuxt.config.ts`. :: diff --git a/docs/1.getting-started/3.views.md b/docs/1.getting-started/3.views.md index a3275b05c2..e169bdfa66 100644 --- a/docs/1.getting-started/3.views.md +++ b/docs/1.getting-started/3.views.md @@ -1,7 +1,7 @@ --- title: 'Views' description: 'Nuxt provides several component layers to implement the user interface of your application.' -navigation.icon: i-ph-layout-duotone +navigation.icon: i-ph-layout --- ## `app.vue` diff --git a/docs/1.getting-started/4.assets.md b/docs/1.getting-started/4.assets.md index ac0b964a2e..a46f973deb 100644 --- a/docs/1.getting-started/4.assets.md +++ b/docs/1.getting-started/4.assets.md @@ -1,7 +1,7 @@ --- title: 'Assets' description: 'Nuxt offers two options for your assets.' -navigation.icon: i-ph-image-duotone +navigation.icon: i-ph-image --- Nuxt uses two directories to handle assets like stylesheets, fonts or images. diff --git a/docs/1.getting-started/4.styling.md b/docs/1.getting-started/4.styling.md index aac7cc8166..383bed144b 100644 --- a/docs/1.getting-started/4.styling.md +++ b/docs/1.getting-started/4.styling.md @@ -1,7 +1,7 @@ --- title: 'Styling' description: 'Learn how to style your Nuxt application.' -navigation.icon: i-ph-palette-duotone +navigation.icon: i-ph-palette --- Nuxt is highly flexible when it comes to styling. Write your own styles, or reference local and external stylesheets. @@ -77,10 +77,26 @@ h1 { You can also reference stylesheets that are distributed through npm. Let's use the popular `animate.css` library as an example. -```bash [Terminal] +::package-managers + +```bash [npm] npm install animate.css ``` +```bash [yarn] +yarn add animate.css +``` + +```bash [pnpm] +pnpm install animate.css +``` + +```bash [bun] +bun install animate.css +``` + +:: + Then you can reference it directly in your pages, layouts and components: ```vue [app.vue] @@ -411,8 +427,8 @@ Nuxt comes with postcss built-in. You can configure it in your `nuxt.config` fil export default defineNuxtConfig({ postcss: { plugins: { - 'postcss-nested': {} - "postcss-custom-media": {} + 'postcss-nested': {}, + 'postcss-custom-media': {} } } }) diff --git a/docs/1.getting-started/5.routing.md b/docs/1.getting-started/5.routing.md index e39d5d446b..e732502f6c 100644 --- a/docs/1.getting-started/5.routing.md +++ b/docs/1.getting-started/5.routing.md @@ -1,7 +1,7 @@ --- title: 'Routing' description: Nuxt file-system routing creates a route for every file in the pages/ directory. -navigation.icon: i-ph-signpost-duotone +navigation.icon: i-ph-signpost --- One core feature of Nuxt is the file system router. Every Vue file inside the [`pages/`](/docs/guide/directory-structure/pages) directory creates a corresponding URL (or route) that displays the contents of the file. By using dynamic imports for each page, Nuxt leverages code-splitting to ship the minimum amount of JavaScript for the requested route. diff --git a/docs/1.getting-started/5.seo-meta.md b/docs/1.getting-started/5.seo-meta.md index a1ebb2f457..46a3f2298d 100644 --- a/docs/1.getting-started/5.seo-meta.md +++ b/docs/1.getting-started/5.seo-meta.md @@ -1,7 +1,7 @@ --- title: SEO and Meta description: Improve your Nuxt app's SEO with powerful head config, composables and components. -navigation.icon: i-ph-file-search-duotone +navigation.icon: i-ph-file-search --- ## Defaults @@ -128,8 +128,6 @@ See [@unhead/schema](https://github.com/unjs/unhead/blob/main/packages/schema/sr Reactivity is supported on all properties, by providing a computed value, a getter, or a reactive object. -It's recommended to use getters (`() => value`) over computed (`computed(() => value)`). - ::code-group ```vue twoslash [useHead] diff --git a/docs/1.getting-started/5.transitions.md b/docs/1.getting-started/5.transitions.md index 6123b64789..dcef4b284e 100644 --- a/docs/1.getting-started/5.transitions.md +++ b/docs/1.getting-started/5.transitions.md @@ -1,7 +1,7 @@ --- title: 'Transitions' description: Apply transitions between pages and layouts with Vue or native browser View Transitions. -navigation.icon: i-ph-exclude-square-duotone +navigation.icon: i-ph-exclude-square --- ::note @@ -328,7 +328,7 @@ definePageMeta({ }, middleware (to, from) { if (to.meta.pageTransition && typeof to.meta.pageTransition !== 'boolean') - to.meta.pageTransition.name = +to.params.id > +from.params.id ? 'slide-left' : 'slide-right' + to.meta.pageTransition.name = +to.params.id! > +from.params.id! ? 'slide-left' : 'slide-right' } }) @@ -392,7 +392,7 @@ The page now applies the `slide-left` transition when going to the next id and ` ## Transition with NuxtPage -When `` is used in `app.vue`, transition-props can be passed directly as a component props to activate global transition. +When `` is used in `app.vue`, transitions can be configured with the `transition` prop to activate transitions globally. ```vue [app.vue]