serverless-build-client is a Serverless Framework plugin, currently at version 2.5.0. Its release cadence appears to be maintenance-driven rather than rapid feature development, with the last code commit being five years ago, and v2.5.0 itself being two years old. The plugin is designed to streamline the frontend build process within a Serverless project. Its primary function is to inject environment variables defined in `serverless.yml` (either globally at the provider level or specifically for the plugin) directly into the client-side build environment. This addresses a common challenge in serverless architectures where frontend applications often need dynamic values, such as API endpoints or resource identifiers, that are provisioned by the backend Serverless service. It integrates seamlessly with static site hosting plugins like `serverless-finch` by ensuring the frontend is built with correct environment configurations before deployment. Users define their build command and preferred package manager (npm or yarn), and the plugin handles the environment variable injection and execution of the build script in the specified working directory.
npm install serverless-build-clientVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to configure the `serverless-build-client` plugin in `serverless.yml` to inject environment variables into a frontend application build. It shows both global provider environment variables and plugin-specific overrides, using `npm` as the packager and a custom build command from a `frontend` subdirectory. The client build then consumes these injected variables.
Review the precedence rules for environment variables to ensure the correct values are being injected into your client build. Plugin-specific variables take precedence.
Set `cwd: frontend` (or your client's directory name) in `custom.buildClient` within `serverless.yml`, or use `serverless client build --cwd frontend`.
Consult your frontend framework/bundler documentation on how to expose Node.js `process.env` variables to the client-side code (e.g., `REACT_APP_VARIABLE_NAME` for Create React App, `VITE_VARIABLE_NAME` for Vite).
Ensure you have `yarn add --dev serverless-build-client` (or `npm install --save-dev serverless-build-client`) and that `- serverless-build-client` is present under the `plugins:` section in your `serverless.yml`.
Verify that your client's `package.json` file in the specified `cwd` (or service root) contains a `scripts.build` entry, and that the command itself runs successfully independently. Check the full error output for details from the client build process.
Ensure your environment variables are named according to your frontend framework's conventions (e.g., `REACT_APP_` for Create React App, `VITE_` for Vite) or explicitly configured for exposure in your bundler settings.
No dependency data recorded yet.