Skip to content

Commit 6011ab6

Browse files
amondnetCopilot
andauthored
refactor: migrate example configs from vercel.json to vercel.ts (#300)
* refactor: migrate example configs from vercel.json to vercel.ts - Replace deprecated vercel.json with vercel.ts using @vercel/config/v1 in all 4 examples - Update README.md to recommend vercel.ts alongside vercel.json - Replace deprecated github.enabled with git.deploymentEnabled - Update documentation links to current Vercel docs * fix: add git.deploymentEnabled to express-basic-auth and static examples * chore: apply AI code review suggestions - Fix header rule ordering in angular vercel.ts (catch-all first, specific last) - Remove no-op robots.txt rewrite rule - Fix favicon.ico rewrite destination typo (txt -> ico) - Add "public": false to vercel.json example in README * fix: restore robots.txt identity rewrite to prevent SPA catch-all override Without the identity rewrite, requests for robots.txt fall through to the catch-all rewrite and serve index.html instead of the static file, breaking SEO crawlability. * fix: replace @vercel/config imports with plain objects and fix angular config placement - Remove runtime `routes` import from express-basic-auth/vercel.ts; use plain rewrite object - Remove `import type VercelConfig` from nextjs and static vercel.ts files for consistency - Replace example/angular/vercel.ts (root) with src/vercel.json so Angular copies it to dist/angular/ during build (the deployed directory) - Update angular.json assets from stale src/now.json to src/vercel.json Co-authored-by: amondnet <1964421+amondnet@users.noreply.github.com> Agent-Logs-Url: https://github.com/amondnet/vercel-action/sessions/8059a005-9fad-4cfe-b31f-59bf1b0ab64f * fix: ignore markdown files in eslint config * chore: add @vercel/config as devDependency to examples * chore: remove unused @vercel/config dependency from example packages - express-basic-auth: vercel.ts uses plain objects, no imports needed - nextjs: vercel.ts uses plain objects, no imports needed - angular: now uses src/vercel.json (plain JSON), no vercel.ts imports --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: amondnet <1964421+amondnet@users.noreply.github.com>
1 parent 50bbfcf commit 6011ab6

File tree

10 files changed

+93
-65
lines changed

10 files changed

+93
-65
lines changed

README.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,40 @@ The name of deployment name.
6969
### Disable Vercel for GitHub
7070

7171
> The Vercel for GitHub integration automatically deploys your GitHub projects with Vercel, providing Preview Deployment URLs, and automatic Custom Domain updates.
72-
[link](https://vercel.com/docs/v2/git-integrations)
72+
> See [Git Configuration](https://vercel.com/docs/project-configuration/git-configuration) for more details.
7373
74-
We would like to to use `github actions` for build and deploy instead of `Vercel`.
74+
We would like to use `github actions` for build and deploy instead of `Vercel`.
7575

76-
Set `github.enabled: false` in `vercel.json`, see example `vercel.json` file below:
76+
Disable automatic deployments by setting `git.deploymentEnabled: false` in your project configuration.
77+
78+
#### Using `vercel.ts` (recommended)
79+
80+
Install `@vercel/config` and create a `vercel.ts` file:
81+
82+
```typescript
83+
import type { VercelConfig } from '@vercel/config/v1';
84+
85+
export const config: VercelConfig = {
86+
public: false,
87+
git: {
88+
deploymentEnabled: false,
89+
},
90+
};
91+
```
92+
93+
#### Using `vercel.json`
7794

7895
```json
7996
{
80-
"version": 2,
8197
"public": false,
82-
"github": {
83-
"enabled": false
98+
"git": {
99+
"deploymentEnabled": false
84100
}
85101
}
86102
```
87-
When `github.enabled` set to `false`, `Vercel for GitHub` will not deploy the given project regardless of the GitHub app being installed.
103+
104+
> **Note:** The `github.enabled` property is deprecated. Use `git.deploymentEnabled` instead.
105+
> See [Turning off all automatic deployments](https://vercel.com/docs/project-configuration/git-configuration#turning-off-all-automatic-deployments).
88106
89107
### Skip vercel's build step
90108

@@ -99,20 +117,29 @@ Since we do the `build` in `github actions`, we don't need to build in `vercel`.
99117

100118
See [docs](https://vercel.com/docs/concepts/deployments/build-step#build-command) for more details
101119

102-
#### Method 2 - via `vercel.json`
120+
#### Method 2 - via project configuration
121+
122+
You can override the build command in your project configuration to skip Vercel's build step.
123+
124+
**`vercel.ts`** (recommended):
125+
126+
```typescript
127+
import type { VercelConfig } from '@vercel/config/v1';
128+
129+
export const config: VercelConfig = {
130+
buildCommand: '',
131+
};
132+
```
103133

104-
If a Deployment defines the builds configuration property, the vercel's `Build & Development Settings` are ignored.
134+
**`vercel.json`**:
105135

106136
```json
107137
{
108-
"builds": [
109-
{ "src": "{{Source for distribution}}", "use": "@vercel/static" }
110-
]
138+
"buildCommand": ""
111139
}
112140
```
113-
Set `builds` to `@vercel/static` to skip vercel's build step. `src` is the path to the directory containing the files to be deployed.
114141

115-
See [docs](https://vercel.com/docs/cli#legacy/builds) for more details
142+
See [Build Command docs](https://vercel.com/docs/deployments/configure-a-build#build-command) and [Programmatic Configuration](https://vercel.com/docs/project-configuration/vercel-ts) for more details.
116143

117144
### Project Linking
118145

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default antfu({
1212
'example/**',
1313
'node_modules/**',
1414
'*.min.js',
15+
'**/*.md',
1516
],
1617
languageOptions: {
1718
globals: {

example/angular/angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"assets": [
2323
"src/favicon.ico",
2424
"src/assets",
25-
"src/now.json"
25+
"src/vercel.json"
2626
],
2727
"styles": [
2828
"src/styles.css"

example/angular/src/vercel.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
{
2-
"name": "zeit-now-deployment-action-example-angular",
3-
"version": 2,
4-
"scope": "amond",
52
"public": false,
6-
"github": {
7-
"enabled": false
3+
"git": {
4+
"deploymentEnabled": false
85
},
9-
"routes": [
6+
"headers": [
107
{
11-
"src": "/(assets/.+|amcharts/.+|.+\\.css|.+\\.js|.+\\.eot|.+\\.svg|.+\\.ttf|.+\\.woff|.+\\.gif|.+\\.png|.+\\.jpg)",
12-
"headers": { "cache-control": "max-age=31536000,immutable" },
13-
"dest": "/$1"
8+
"source": "/(assets/.+|amcharts/.+|.+\\.css|.+\\.js|.+\\.eot|.+\\.svg|.+\\.ttf|.+\\.woff|.+\\.gif|.+\\.png|.+\\.jpg)",
9+
"headers": [
10+
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
11+
]
1412
},
1513
{
16-
"src": "/(.*).html",
17-
"headers": { "cache-control": "public,max-age=0,must-revalidate" },
18-
"dest": "/$1.html"
14+
"source": "/(.*).html",
15+
"headers": [
16+
{ "key": "Cache-Control", "value": "public, max-age=0, must-revalidate" }
17+
]
1918
},
2019
{
21-
"src": "/(.*)",
22-
"headers": { "cache-control": "public,max-age=0,must-revalidate" },
23-
"dest": "/index.html"
24-
},
25-
{ "src": "/robots.txt", "dest": "/robots.txt" },
26-
{ "src": "/favicon.ico", "dest": "/favicon.txt" }
20+
"source": "/(.*)",
21+
"headers": [
22+
{ "key": "Cache-Control", "value": "public, max-age=0, must-revalidate" }
23+
]
24+
}
25+
],
26+
"rewrites": [
27+
{ "source": "/robots.txt", "destination": "/robots.txt" },
28+
{ "source": "/favicon.ico", "destination": "/favicon.ico" },
29+
{ "source": "/(.*)", "destination": "/index.html" }
2730
]
2831
}

example/express-basic-auth/vercel.json

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const config = {
2+
public: false,
3+
git: {
4+
deploymentEnabled: false,
5+
},
6+
functions: {
7+
'index.js': {
8+
includeFiles: '_static/**/*.js',
9+
},
10+
},
11+
rewrites: [
12+
{
13+
source: '/(.*)',
14+
destination: '/index.js',
15+
},
16+
],
17+
};

example/nextjs/vercel.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

example/nextjs/vercel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const config = {
2+
public: false,
3+
git: {
4+
deploymentEnabled: false,
5+
},
6+
};

example/static/vercel.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

example/static/vercel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const config = {
2+
public: false,
3+
git: {
4+
deploymentEnabled: false,
5+
},
6+
};

0 commit comments

Comments
 (0)