-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserverless.yml
More file actions
223 lines (194 loc) · 10.1 KB
/
serverless.yml
File metadata and controls
223 lines (194 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# CloudFormation output name: `sls-${SERVICE_NAME}-${STAGE}`
service: sls-${self:custom.service}
package:
individually: true
custom:
service: ${env:SERVICE_NAME}
region: ${opt:region, env:AWS_REGION}
stage: ${opt:stage, env:STAGE}
# Old serverless-offline has hard-coded runtime constraint checks.
# `AWS_NODEJS_RUNTIME=nodejs14.x` will work as a hack for it.
runtime: ${env:AWS_NODEJS_RUNTIME, "nodejs22.x"}
jetpack:
preInclude:
- "!**" # Start with no files at all.
trace:
ignores:
# Provided on Lambda
- "aws-sdk"
# Stuff Next.js trace mode ignores.
# https://github.com/vercel/next.js/blob/ab40370ea5b69aa4dd601907eb85d25da1140b6b/packages/next/build/index.ts#L1257-L1280
# https://unpkg.com/browse/next@12.1.0/dist/build/index.js (L765-L777)
# https://github.com/vercel/next.js/blob/v13.0.2/packages/next/build/index.ts#L1807-L1823
- "next/dist/compiled/webpack/bundle5"
- "webpack5"
# Ignore real deps in Next.js that we shouldn't need at runtime.
- "caniuse-lite"
- "postcss"
- "webpack"
allowMissing:
"node-fetch":
- "encoding"
"next":
- "critters" # for CSS optimization
- "pnpapi" # for PnP usage
- "fibers" # Part of sass-loader
- "@next/font" # Optional next font loading
# If using `experimental.nextScriptWorkers = true` you'll need to remove
# this allowMissing and `npm install --save @builder.io/partytown`
# See: https://nextjs.org/docs/basic-features/script#off-loading-scripts-to-a-web-worker-experimental
- "@builder.io/partytown"
# ... and here too for partytown.
"./.next/server/pages/_document.js":
- "@builder.io/partytown"
dynamic:
resolutions:
# Sources
# -------
# Our servers do lazy requires of pages.
"./server/blog.js": []
"./server/root.js": []
# Built
# -----
# Webpack chunk loading
# .next/server/webpack-api-runtime.js [131:27]: require("./chunks/" + __webpack_require__.u(chunkId))
# .next/server/webpack-runtime.js [143:27]: require("./chunks/" + __webpack_require__.u(chunkId))
"./.next/server/webpack-api-runtime.js": []
"./.next/server/webpack-runtime.js": []
# Dependencies
# ------------
# express/lib/view.js [81:13]: require(mod)
"express/lib/view.js": []
# Optional optimizer.
# next/dist/compiled/@ampproject/toolbox-optimizer/index.js [1:21249]: require.resolve(e)
"next/dist/compiled/@ampproject/toolbox-optimizer/index.js": []
# Webpack plugin tool.
# next/dist/compiled/cssnano-simple/index.js [1:21238]: require.resolve(name,{paths:[".",ctx.path]})
# next/dist/compiled/cssnano-simple/index.js [1:21676]: require(__nccwpck_require2_(8440).resolve(path.join(v,"browserslist-stats.json"),{paths:["."]}))
# next/dist/compiled/cssnano-simple/index.js [1:22728]: require("caniuse-lite/data/regions/"+y+".js")
# next/dist/compiled/cssnano-simple/index.js [1:22968]: require("caniuse-lite/data/features/"+v+".js")
"next/dist/compiled/cssnano-simple/index.js": []
# Dynamic require function
# From: https://github.com/vercel/edge-runtime/blob/cec1f8493e14465692eec5f672cdb916b51e8e84/packages/vm/src/require.ts#L30-L77
# next/dist/compiled/edge-runtime/index.js [1:6716]: require.resolve(c,{paths:[(0,s.dirname)(a)]})
"next/dist/compiled/edge-runtime/index.js": []
# next/dist/compiled/jest-worker/index.js [1:7889]: require.resolve(e)
# next/dist/compiled/jest-worker/index.js [1:22455]: require(e)
"next/dist/compiled/jest-worker/index.js": []
# Next13 next-server adds in a webpack / Node.js patching hook (ugh!) as well as
# compiled-in versions of libraries that we need to address.
# See
# - https://github.com/vercel/next.js/blob/v13.0.2/packages/next/server/next-server.ts#L1
# - https://github.com/vercel/next.js/blob/v13.0.2/packages/next/build/webpack/require-hook.ts
#
# Note diff from:
# - https://github.com/vercel/next.js/blob/v12.3.2/packages/next/server/next-server.ts
# These libraries require root "react-dom" which now should have the built-in index.
"next/dist/compiled/react-dom/cjs/react-dom-server-legacy.browser.development.js":
- "next/dist/compiled/react-dom/index.js"
"next/dist/compiled/react-dom/cjs/react-dom-server-legacy.browser.production.min.js":
- "next/dist/compiled/react-dom/index.js"
# Dynamically look up package versions.
# next/dist/lib/get-package-version.js [88:27]: require.resolve(`${name}/package.json`, {
"next/dist/lib/get-package-version.js": []
# Webpack build time replacements in `loadWebpackHook`
# next/dist/server/config-utils.js [188:12]: require.resolve(replacement)
"next/dist/server/config-utils.js": []
# Dynamically require config path provided by user.
# next/dist/server/config.js [68:35]: require(path)
# next/dist/server/config.js [70:41]: import((0, _url).pathToFileURL(path).href)
"next/dist/server/config.js": []
# next/dist/server/image-optimizer.js [54:12]: require(process.env.NEXT_SHARP_PATH || "sharp")
"next/dist/server/image-optimizer.js": []
# next/dist/server/lib/incremental-cache/index.js [29:30]: require(incrementalCacheHandlerPath)
"next/dist/server/lib/incremental-cache/index.js": []
# next/dist/server/load-components.js [22:23]: require((0, _path).join(distDir, `fallback-${_constants.BUILD_MANIFEST}`))
# next/dist/server/load-components.js [39:8]: require((0, _path).join(distDir, _constants.BUILD_MANIFEST))
# next/dist/server/load-components.js [40:8]: require((0, _path).join(distDir, _constants.REACT_LOADABLE_MANIFEST))
# next/dist/server/load-components.js [41:30]: require((0, _path).join(distDir, "server", _constants.FLIGHT_MANIFEST + ".json"))
"next/dist/server/load-components.js": []
# Runtime build directory imports.
# next/dist/server/next-server.js [149:15]: require((0, _path).join(this.serverDistDir, _constants.PAGES_MANIFEST))
# next/dist/server/next-server.js [154:19]: require(appPathsManifestPath)
# next/dist/server/next-server.js [469:33]: require(builtPagePath)
# next/dist/server/next-server.js [587:15]: require((0, _path).join(this.distDir, "server", _constants.FLIGHT_MANIFEST + ".json"))
# next/dist/server/next-server.js [591:15]: require((0, _path).join(this.distDir, "server", _constants.FLIGHT_SERVER_CSS_MANIFEST + ".json"))
# next/dist/server/next-server.js [595:15]: require((0, _path).join(this.distDir, "server", `${_constants.FONT_LOADER_MANIFEST}.json`))
# next/dist/server/next-server.js [988:25]: require((0, _path).join(this.serverDistDir, _constants.MIDDLEWARE_MANIFEST))
# next/dist/server/next-server.js [1018:25]: require((0, _path).join(this.serverDistDir, _constants.MIDDLEWARE_MANIFEST))
# next/dist/server/next-server.js [1341:25]: require((0, _path).join(this.distDir, _constants.PRERENDER_MANIFEST))
# next/dist/server/next-server.js [1345:15]: require((0, _path).join(this.distDir, _constants.ROUTES_MANIFEST))
"next/dist/server/next-server.js": []
# next/dist/server/require.js [39:27]: require((0, _path).join(serverBuildPath, _constants.APP_PATHS_MANIFEST))
# next/dist/server/require.js [41:26]: require((0, _path).join(serverBuildPath, _constants.PAGES_MANIFEST))
# next/dist/server/require.js [88:11]: require(pagePath)
# next/dist/server/require.js [92:25]: require((0, _path).join(serverBuildPath, _constants.FONT_MANIFEST))
"next/dist/server/require.js": []
plugins:
- serverless-jetpack
- serverless-offline
provider:
name: aws
# Lambda configuration
runtime: ${self:custom.runtime}
timeout: 30 # seconds (`300` max)
memorySize: 1024 # MB value (`1024` default)
# Deployment / environment configuration
region: ${self:custom.region}
stage: ${self:custom.stage}
environment:
STAGE: ${self:custom.stage}
SERVICE_NAME: ${self:custom.service}
NODE_ENV: production
# AWS Resource Tags
stackTags: # For CF stack
Stage: ${self:custom.stage}
Service: ${self:custom.service}
tags: # For resources
Stage: ${self:custom.stage}
Service: ${self:custom.service}
# TODO(STATIC): Allows serving of binary media. Shouldn't use this for real.
apiGateway:
binaryMediaTypes:
- "*/*"
functions:
# SCENARIO - base: The simplest, vanilla Serverless app.
blog:
handler: server/blog.handler
environment:
BASE_PATH: /blog
events: # Use a generic proxy to allow Express app to route.
- http: ANY /blog
- http: 'ANY /blog/{proxy+}'
jetpack:
trace:
include:
# Next.js config/generated files: gather dependencies
- "next.config.js"
- ".next/server/**/*.js"
package:
include:
# Raw data for posts is read from disk outside `.next` build directory.
- "src/posts/**/*.md"
# Needed built Next.js assets and info. (Some of these are also traced).
- ".next/BUILD_ID"
- ".next/*.json"
- ".next/server/**"
# Ignore all NFT files.
- "!**/*.nft.json"
# TODO(STATIC): Should be served outside Lambda in real production.
- ".next/static/**"
- "public/images/**"
# TODO(STATIC): Simple static server for root assets.
root:
handler: server/root.handler
environment:
BASE_PATH: /
events: # Use a generic proxy to allow Express app to route.
- http: ANY /
- http: 'ANY /{proxy+}'
package:
include:
# TODO(STATIC): Should be served outside Lambda in real production.
# Only favicon is served from root handler.
- "public/favicon.ico"