Netlify
Tags
Netlify
Words count
373 字
Reading time
2 分钟
config
toml
# 全局构建配置
[build]
# 构建命令
command = "pnpm build"
# 发布目录
publish = "dist"
# 函数目录
functions = "functions"
# 生产环境配置
[context.production]
# 生产环境构建命令
command = "pnpm build"
# 生产环境发布目录
publish = "dist"
# 生产环境函数目录
functions = "functions"
# 预览部署配置(针对拉取请求)
[context.deploy-preview]
# 预览部署构建命令
command = "pnpm build"
# 预览部署发布目录
publish = "dist"
# 预览部署函数目录
functions = "functions"
# 分支部署配置(针对特定分支)
[context.branch-deploy]
# 分支部署构建命令
command = "pnpm build"
# 分支部署发布目录
publish = "dist"
# 分支部署函数目录
functions = "functions"
# 开发环境配置
[dev]
# 开发环境命令
command = "pnpm start"
# 开发环境端口
port = 3000
# 开发环境目标端口
targetPort = 3000
# 函数配置
[functions]
# 函数目录
directory = "functions"
# 函数内存限制(可选)
memory = 1024
# 函数超时时间(可选)
timeout = 10
# 重写和重定向配置
[[redirects]]
# 来源路径
from = "/old-path"
# 目标路径
to = "/new-path"
# 状态码(可选,默认301)
status = 301
# 强制重定向(可选)
force = false
# 头部配置
[[headers]]
# 作用路径
for = "/index.html"
[headers.values]
# 自定义头部
X-Custom-Header = "MyValue"
# 环境变量配置
[context.production.environment]
# 环境变量
NODE_ENV = "production"
# 缓存配置
[cache]
# 缓存目录
directory = "node_modules"
# 重写配置(用于单页应用)
[[redirects]]
from = "/*"
to = "/index.html"
status = 200