diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5ed37e5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.devcontainer/** linguist-vendored diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e5e3262..650060e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -127,18 +127,17 @@ jobs: with: fetch-depth: 25 - - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + - name: Fetch git tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - name: Cache - uses: actions/cache@v2 + - name: Setup node + uses: actions/setup-node@v2 with: - path: | - .yarn - **/node_modules - key: e2e-${{ hashFiles('yarn.lock') }} + node-version: '14' + cache: 'yarn' - name: Install dependencies - run: yarn install --frozen-lockfile --check-files + run: yarn --frozen-lockfile - name: Download build artifact uses: actions/download-artifact@v2 @@ -146,4 +145,12 @@ jobs: name: lambda path: lib - - run: ./scripts/publish-release.sh + # git user is required (bot not used) by release-it + - name: Set git user to GitHub Actions + uses: fregante/setup-git-user@v1.0.1 + + - name: Set registry for publish + run: yarn config set registry https://registry.npmjs.org + + - name: Publish packages + run: ./scripts/publish-release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02e2501..fb97a67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: release-branch: release release-tag: ${{ github.event.inputs.tag }} exclude: | + .devcontainer/**/* .vscode/**/* lib/**/* scripts/**/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 106d9b3..6927a7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # Changelog -## 12.0.1 (December 21, 2021) +## [Unreleased] + +## [12.0.2] - 2022-01-22 + +- 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)) +- Use relative path as lambda function local package path ([#98](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/98)) + +## [12.0.1] (December 21, 2021) 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). In addition you can now define a new input variable `next_image_base_origin` that can be used to resolve absolute image paths. diff --git a/README.md b/README.md index 9367290..5aff29e 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,9 @@ Then rebuild and redeploy your Next.js application to make use of the changed co ## Examples -- [Statically exported Next.js app hosted on S3](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) +- [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) Use the image optimizer together with a statically exported Next.js app that is deployed to S3 and CloudFront. -- [Next.js + Vercel](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js-export) +- [Next.js + Vercel](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) Use the image optimizer together with a Next.js app deployed on Vercel. - [Existing CloudFront](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront) 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 | next\_image\_domains | Allowed origin domains that can be used for fetching images. | `list(string)` | `[]` | no | | 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)` |
[
"image/webp"
]
| no | | next\_image\_image\_sizes | Allowed image sizes that should be used for image optimization. | `list(number)` | `null` | no | -| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.0.1"` | no | +| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.0.2"` | no | | 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 | | tags | Tag metadata to label AWS resources that support tags. | `map(string)` | `{}` | no | diff --git a/examples/with-next-js-export/README.md b/examples/with-next-js-export/README.md index a9891a1..06a49b2 100644 --- a/examples/with-next-js-export/README.md +++ b/examples/with-next-js-export/README.md @@ -59,17 +59,7 @@ After Terraform has successfully created all resources in your AWS account, you > website_bucket_id = "next-image-optimizer-example-export" ``` -### 3. Adjust Next.js config - -In the Next.js project, open the `next.config.js` file and add the following lines (Remember to replace `` with the output from the previous step): - -```diff -// next.config.js -+ const domainName = 'xxxxxxxxxxxxxxxxx.cloudfront.net'; -- const domainName = '.cloudfront.net'; -``` - -### 4. Build and export the Next.js site +### 3. Build and export the Next.js site To create a static build of Next.js we need to run two commands. `next build` builds the production site in the `.next/` folder. @@ -77,12 +67,12 @@ To create a static build of Next.js we need to run two commands. ```sh npm run build # Builds the Next.js site -npm run export # Prepares the +npm run export # Prepares the build output for upload to S3 ``` After running the two commands you should see a new folder named `out/` in your project, where the statically exported site is exported to. -### 5. Upload the Next.js site to S3 +### 4. Upload the Next.js site to S3 To upload the content of the `out/` folder we use the [AWS CLI](https://aws.amazon.com/cli/). Make sure to replace `` with the output from step 2 before running the command: @@ -94,7 +84,7 @@ aws s3 sync ./out s3:// --- Your website should now be accessible on the CloudFront domain `.cloudfront.net` you got from step 2. -To update your site, simply repeat step 4. & 5 of this guide. +To update your site, simply repeat step 3 & 4 of this guide. ## Caveats diff --git a/examples/with-next-js-export/next.config.js b/examples/with-next-js-export/next.config.js index 25a5371..99696b7 100644 --- a/examples/with-next-js-export/next.config.js +++ b/examples/with-next-js-export/next.config.js @@ -1,5 +1,3 @@ -const domainName = '.cloudfront.net'; - module.exports = (phase) => { const isExport = phase === 'phase-export'; @@ -11,7 +9,6 @@ module.exports = (phase) => { loader: isExport ? 'custom' : 'default', domains: ['assets.vercel.com'], formats: ['image/avif', 'image/webp'], - path: `https://${domainName}/_next/image`, }, /** diff --git a/examples/with-next-js-export/pages/shimmer.js b/examples/with-next-js-export/pages/shimmer.js index 7c2cf6d..09a31a3 100644 --- a/examples/with-next-js-export/pages/shimmer.js +++ b/examples/with-next-js-export/pages/shimmer.js @@ -27,7 +27,7 @@ const Shimmer = () => (

Image Component With Shimmer Data URL