You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 1, 2025. It is now read-only.
-[ ] Bundle Sharp together with image optimizer so Next uses it.
49
48
50
49
51
50
## Usage
@@ -103,39 +102,13 @@ Update of stack:
103
102
104
103
We are looking at 6-8min for creation and 1-3min for update. This is a huge improvement over existing Lambda@Edge implementation.
105
104
106
-
### Sharp layer
107
-
108
-
Besides handler (wrapper) itself, underlying NextJS also requires sharp binaries.
109
-
To build those, we use `npm install` with some extra parametes. Then we zip all sharp dependencies and compress it to easily importable zip file.
110
-
111
-
```
112
-
import { sharpLayerZipPath } from '@sladg/nextjs-lambda'
113
-
114
-
const sharpLayer = new LayerVersion(this, 'SharpDependenciesLayer', {
115
-
code: Code.fromAsset(sharpLayerZipPath)
116
-
})
117
-
```
118
-
119
-
### Next layer
120
-
121
-
To provide both image and server handlers with all depdencies (next is using `require.resolve` inside, so it cannot be bundled standalone for now).
122
-
123
-
We pre-package this layer so it can be included in Lambda without hassle.
124
-
```
125
-
import { nextLayerZipPath } from '@sladg/nextjs-lambda'
126
-
127
-
const nextLayer = new LayerVersion(this, 'NextDependenciesLayer', {
128
-
code: Code.fromAsset(nextLayerZipPath)
129
-
})
130
-
```
131
-
132
105
## Packaging
133
106
134
107
In order to succefully deploy, you firstly need to include `target: 'standalone'` in your `next.config.js` setup.
135
108
Make sure to use NextJS in version 12 or above so this is properly supported.
136
109
137
110
Once target is set, you can go on and use your `next build` command as you normally would.
138
-
To package everything, make sure to be in your project root folder and next folder `.next` and `public` exist. Packaging is done via NPM CLI command of `@slack/nextjs-lambda package`.
111
+
To package everything, make sure to be in your project root folder and next folder `.next` and `public` exist. Packaging is done via NPM CLI command of `@slack/nextjs-lambda pack`.
139
112
140
113
It will create `next.out/` folder with 3 zip packages. One zip Lambda's code, one is dependencies layer and one is assets layer.
0 commit comments