cdk-nuxt 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/lib/cli/deploy.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Easily deploy a dynamic universal Nuxt application via CDK on AWS including the
|
|
|
29
29
|
yarn add cdk-nuxt --dev # The package itself
|
|
30
30
|
yarn add ts-node typescript --dev # To compile the CDK stacks via typescript
|
|
31
31
|
yarn add aws-cdk@2.15.0 --dev # CDK cli with this exact version for the deployment
|
|
32
|
-
yarn add nuxt-aws-lambda nuxt-start # To make the Nuxt app renderable via
|
|
32
|
+
yarn add nuxt-aws-lambda nuxt-start # To make the Nuxt app renderable via the default Lambda handler (not required when using your own Lambda handler)
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
2. Move the `nuxt` dependency to `devDependencies` as we installed `nuxt-start` to start our Nuxt app.<br/>Also, make sure that only the dependencies required for server-side rendering (SSR) are listed under `dependencies` to have the Lambda function and its layer as small as possible for better performance and to respect the [Lambda size limits](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html). Every other dependency should be under `devDependencies`.
|
|
@@ -95,6 +95,21 @@ After the installation and the setup you are already good to go to build the Nux
|
|
|
95
95
|
```
|
|
96
96
|
The deployment script will take care of installing only the dependencies that are required for the Nuxt app and deploying the Nuxt build files to AWS according to the stack settings in `stack/index.ts`.<br/>See the section Used AWS Resources for details on which resources will exactly be created on AWS.
|
|
97
97
|
|
|
98
|
+
## Optional: Customize the Lambda handler
|
|
99
|
+
|
|
100
|
+
The package takes advantage of the `nuxt-start` and `aws-lambda` modules to automatically provide a Lambda handler for the Nuxt app.
|
|
101
|
+
If you need more control over the entrypoint of the Lambda function, e.g., for adding additional logging or performance monitoring, feel free to specify your own handler within a file `server/index.js` within your root directory.
|
|
102
|
+
If a file `server/index.js` exists, the package will use this file as the entrypoint for the Lambda.
|
|
103
|
+
The file `server/index.js` must export a function called `handler` to work properly.
|
|
104
|
+
Feel free to take the following content of the package's default handler as a template:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
const { createNuxtHandler } = require('nuxt-aws-lambda')
|
|
108
|
+
const config = require('./nuxt.config.js')
|
|
109
|
+
|
|
110
|
+
module.exports.handler = createNuxtHandler(config)
|
|
111
|
+
```
|
|
112
|
+
|
|
98
113
|
## Optional: Automatically deploy on every push (CD) via [GitHub Actions](https://github.com/features/actions)
|
|
99
114
|
|
|
100
115
|
Feel free to copy the following GitHub Actions YAML file content into a YAML file at `.github/workflows/deploy.yml` to automatically build and deploy the Nuxt app to AWS on every push to a specific branch.<br/>This only works if you're using GitHub for the project's VCS repository.
|
package/lib/cli/deploy.js
CHANGED
|
@@ -38,7 +38,14 @@ shell.cd(rootFolder);
|
|
|
38
38
|
// Copy our files required for SSR
|
|
39
39
|
shell.echo(`${logPrefix}: Copying ssr files to deployment folder...`);
|
|
40
40
|
shell.cp('-r', '.nuxt/dist/server', `${deploymentSourceFolder}/.nuxt/dist`);
|
|
41
|
-
|
|
41
|
+
|
|
42
|
+
// Copy the Nuxt app handler
|
|
43
|
+
// A custom handler can be specified if one exists within 'server/index.js'
|
|
44
|
+
if (shell.test('-f', 'server/index.js')) {
|
|
45
|
+
shell.cp('server/index.js', deploymentSourceFolder);
|
|
46
|
+
} else {
|
|
47
|
+
shell.cp(path.join(__dirname, '../functions/app/index.js'), deploymentSourceFolder);
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
// Copy the config files
|
|
44
51
|
shell.echo(`${logPrefix}: Copying config files to deployment folder...`);
|