Skip to content

Commit 03e6fb9

Browse files
committed
chore(website): added inline comments
1 parent 2b1a092 commit 03e6fb9

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

package-lock.json

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/scripts.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import { execSync } from "child_process";
22

3+
/**
4+
* This is a custom Serverless Framework Plugin that allows you to
5+
* define and run custom scripts in your serverless.yml file, similar to npm scripts.
6+
* For more information on creating custom plugins, see the documentation:
7+
* https://www.serverless.com/framework/docs/guides/plugins/creating-plugins
8+
*
9+
* In this AI example, we need to run vite build script before deploying the website service.
10+
* So we built this quick plugin, and loaded it in the serverless.yml file.
11+
*/
12+
313
class Scripts {
414
constructor(serverless, options, utils) {
515
this.serverless = serverless;
6-
this.options = options;
7-
this.utils = utils;
16+
this.options = options; // CLI options are passed to the plugin
17+
this.utils = utils; // Helper logging functions are passed to the plugin
818

919
this.commands = {};
1020
this.hooks = {};
@@ -56,12 +66,16 @@ class Scripts {
5666
}
5767

5868
execute(command) {
69+
// By default, only show stderr in the terminal
70+
// So that you can see any build errors that may occur
5971
let stdio = ["ignore", "ignore", "inherit"];
6072

73+
// But in verbose or debug mode, we show all output
6174
if (this.options.verbose || this.options.debug) {
6275
stdio = "inherit";
6376
}
6477

78+
// Execute the command/script in a child service
6579
execSync(command, { stdio });
6680
}
6781
}

website/serverless.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ provider:
55
runtime: nodejs20.x
66

77
plugins:
8-
- serverless-domain-manager
9-
- ./scripts
8+
- serverless-domain-manager # Load the community plugin for custom domains installed with npm
9+
- ./scripts # Load our custom scripts plugin
1010

1111
build:
1212
esbuild: true
@@ -25,6 +25,8 @@ custom:
2525
apiType: http
2626
autoDomain: true
2727
enabled: ${param:customDomainNameEnabled}
28+
29+
# This property is expected by our custom scripts plugin.
2830
scripts:
2931
hooks:
3032
# This hook builds the React App. It sets the environment variables for

0 commit comments

Comments
 (0)