Skip to content

Commit 037429f

Browse files
Merge commit 'd0d611e1f16185093a8b8bd5b315a914976b1714' into release
2 parents 5a76183 + d0d611e commit 037429f

File tree

10 files changed

+37
-34
lines changed

10 files changed

+37
-34
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.devcontainer/** linguist-vendored

.github/workflows/CI.yml

+16-9
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,30 @@ jobs:
127127
with:
128128
fetch-depth: 25
129129

130-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
130+
- name: Fetch git tags
131+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
131132

132-
- name: Cache
133-
uses: actions/cache@v2
133+
- name: Setup node
134+
uses: actions/setup-node@v2
134135
with:
135-
path: |
136-
.yarn
137-
**/node_modules
138-
key: e2e-${{ hashFiles('yarn.lock') }}
136+
node-version: '14'
137+
cache: 'yarn'
139138

140139
- name: Install dependencies
141-
run: yarn install --frozen-lockfile --check-files
140+
run: yarn --frozen-lockfile
142141

143142
- name: Download build artifact
144143
uses: actions/download-artifact@v2
145144
with:
146145
name: lambda
147146
path: lib
148147

149-
- run: ./scripts/publish-release.sh
148+
# git user is required (bot not used) by release-it
149+
- name: Set git user to GitHub Actions
150+
uses: fregante/setup-git-user@v1.0.1
151+
152+
- name: Set registry for publish
153+
run: yarn config set registry https://registry.npmjs.org
154+
155+
- name: Publish packages
156+
run: ./scripts/publish-release.sh

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
release-branch: release
2222
release-tag: ${{ github.event.inputs.tag }}
2323
exclude: |
24+
.devcontainer/**/*
2425
.vscode/**/*
2526
lib/**/*
2627
scripts/**/*

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Changelog
22

3-
## 12.0.1 (December 21, 2021)
3+
## [Unreleased]
4+
5+
## [12.0.2] - 2022-01-22
6+
7+
- Uses Image Optimizer module of [Next.js 12.0.2](https://github.com/vercel/next.js/releases/tag/v12.0.2) ([#101](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/101))
8+
- Use relative path as lambda function local package path ([#98](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/98))
9+
10+
## [12.0.1] (December 21, 2021)
411

512
In this release we fixed a bug that could occur when using absolute image paths (When you use S3 as backend, you are not affected).
613
In addition you can now define a new input variable `next_image_base_origin` that can be used to resolve absolute image paths.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ Then rebuild and redeploy your Next.js application to make use of the changed co
9696

9797
## Examples
9898

99-
- [Statically exported Next.js app hosted on S3](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js)
99+
- [Statically exported Next.js app hosted on S3](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js-export)
100100
Use the image optimizer together with a statically exported Next.js app that is deployed to S3 and CloudFront.
101-
- [Next.js + Vercel](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js-export)
101+
- [Next.js + Vercel](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js)
102102
Use the image optimizer together with a Next.js app deployed on Vercel.
103103
- [Existing CloudFront](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront)
104104
Use the image optimizer with an existing CloudFront distribution.
@@ -140,7 +140,7 @@ Then rebuild and redeploy your Next.js application to make use of the changed co
140140
| next\_image\_domains | Allowed origin domains that can be used for fetching images. | `list(string)` | `[]` | no |
141141
| next\_image\_formats | If the Accept head matches more than one of the configured formats, the first match in the array is used. Therefore, the array order matters. If there is no match, the Image Optimization API will fallback to the original image's format. | `list(string)` | <pre>[<br> "image/webp"<br>]</pre> | no |
142142
| next\_image\_image\_sizes | Allowed image sizes that should be used for image optimization. | `list(number)` | `null` | no |
143-
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.0.1"` | no |
143+
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.0.2"` | no |
144144
| source\_bucket\_id | When your static files are deployed to a Bucket (e.g. with Terraform Next.js) the optimizer can pull the source from the bucket rather than over the internet. | `string` | `null` | no |
145145
| tags | Tag metadata to label AWS resources that support tags. | `map(string)` | `{}` | no |
146146

examples/with-next-js-export/README.md

+4-14
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,20 @@ After Terraform has successfully created all resources in your AWS account, you
5959
> website_bucket_id = "next-image-optimizer-example-export"
6060
```
6161

62-
### 3. Adjust Next.js config
63-
64-
In the Next.js project, open the `next.config.js` file and add the following lines (Remember to replace `<distribution-id>` with the output from the previous step):
65-
66-
```diff
67-
// next.config.js
68-
+ const domainName = 'xxxxxxxxxxxxxxxxx.cloudfront.net';
69-
- const domainName = '<distribution-id>.cloudfront.net';
70-
```
71-
72-
### 4. Build and export the Next.js site
62+
### 3. Build and export the Next.js site
7363

7464
To create a static build of Next.js we need to run two commands.
7565
`next build` builds the production site in the `.next/` folder.
7666
[`next export`](https://nextjs.org/docs/advanced-features/static-html-export) then creates a static HTML export from your site that can be deployed to a static file hosting service like AWS S3.
7767

7868
```sh
7969
npm run build # Builds the Next.js site
80-
npm run export # Prepares the
70+
npm run export # Prepares the build output for upload to S3
8171
```
8272

8373
After running the two commands you should see a new folder named `out/` in your project, where the statically exported site is exported to.
8474

85-
### 5. Upload the Next.js site to S3
75+
### 4. Upload the Next.js site to S3
8676

8777
To upload the content of the `out/` folder we use the [AWS CLI](https://aws.amazon.com/cli/).
8878
Make sure to replace `<bucket-name>` with the output from step 2 before running the command:
@@ -94,7 +84,7 @@ aws s3 sync ./out s3://<bucket-name>
9484
---
9585

9686
Your website should now be accessible on the CloudFront domain `<distribution-id>.cloudfront.net` you got from step 2.
97-
To update your site, simply repeat step 4. & 5 of this guide.
87+
To update your site, simply repeat step 3 & 4 of this guide.
9888

9989
## Caveats
10090

examples/with-next-js-export/next.config.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const domainName = '<distribution-id>.cloudfront.net';
2-
31
module.exports = (phase) => {
42
const isExport = phase === 'phase-export';
53

@@ -11,7 +9,6 @@ module.exports = (phase) => {
119
loader: isExport ? 'custom' : 'default',
1210
domains: ['assets.vercel.com'],
1311
formats: ['image/avif', 'image/webp'],
14-
path: `https://${domainName}/_next/image`,
1512
},
1613

1714
/**

examples/with-next-js-export/pages/shimmer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Shimmer = () => (
2727
<h1>Image Component With Shimmer Data URL</h1>
2828
<Image
2929
alt="Mountains"
30-
src="/mountains.jpg"
30+
src="/mountains.jpeg"
3131
placeholder="blur"
3232
blurDataURL={`data:image/svg+xml;base64,${toBase64(shimmer(700, 475))}`}
3333
width={700}

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
module "lambda_content" {
66
source = "milliHQ/download/npm"
7-
version = "2.0.0"
7+
version = "2.1.0"
88

99
module_name = "@millihq/tf-next-image-optimization"
1010
module_version = var.next_image_version
@@ -36,7 +36,7 @@ module "image_optimizer" {
3636
}
3737

3838
create_package = false
39-
local_existing_package = module.lambda_content.abs_path
39+
local_existing_package = module.lambda_content.rel_path
4040

4141
allowed_triggers = {
4242
AllowExecutionFromAPIGateway = {

variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
variable "next_image_version" {
55
description = "Next.js version from where you want to use the image optimizer from. Supports semver ranges."
66
type = string
7-
default = "12.0.1"
7+
default = "12.0.2"
88
}
99

1010
variable "next_image_base_origin" {

0 commit comments

Comments
 (0)