GCP Storage
Relevant source files
The following files were used as context for generating this wiki page:
GCP Storage is a dedicated Nx plugin that manages file uploads to Google Cloud Storage buckets. It integrates directly into the Nx workspace to automate the deployment of static assets, such as those generated for static site hosting.
Sources: packages/gcp-storage/README.md:9-13, README.md:23-25
Core Functionality
The package provides a specialized executor to handle the transfer of local project files to Google Cloud. It supports advanced features like automatic Gzip compression to optimize web performance and supports multiple upload directories.
Sources: packages/gcp-storage/README.md:9-13, packages/gcp-storage/CHANGELOG.md:126-128
Key Features
- Automated Uploads: Transfers local directories to specified Cloud Storage buckets.
- Compression Support: Applies gzip compression to files during the upload process based on configurable extensions.
- Nx Integration: Provides standard
uploadandpublishtargets compatible with the Nx CLI.
Sources: packages/gcp-storage/README.md:9-13, packages/gcp-storage/CHANGELOG.md:188-190, packages/gcp-storage/project.json:62-67
Architecture and Data Flow
The following diagram illustrates the workflow when a developer executes the upload command.
The diagram shows the process from the initial command to the final file placement in Google Cloud Storage.
Sources: packages/gcp-storage/README.md:19-21, packages/gcp-storage/project.json:8-13
Configuration
GCP Storage configuration resides within the project.json of an application or library. The executor requires specific parameters to identify the destination and the source content.
Executor Options
| Name | Type | Default | Description |
|---|---|---|---|
bucket | string | - | The target Google Cloud Storage bucket name. |
directory | string | - | The full path to the local directory to upload. |
gzip | boolean | false | Enables Gzip compression for the upload. |
gzipExtensions | string | - | Comma-separated list of file extensions to compress. |
Sources: packages/gcp-storage/README.md:27-32, packages/gcp-storage/CHANGELOG.md:154-161
Project Implementation Example
{
"upload": {
"executor": "@nx-extend/gcp-storage:upload",
"options": {
"bucket": "my-static-site",
"directory": "dist/apps/my-app",
"gzip": true,
"gzipExtensions": "html,css,js,json,svg"
}
}
}
Sources: packages/gcp-storage/README.md:46-55
Package Management
The package is part of the nx-extend ecosystem and relies on the @nx/devkit for workspace interaction. It is distributed via NPM under the @nx-extend/gcp-storage scope.
Dependencies and Requirements
- Peer Dependencies: Requires
@nx/devkitversion^22.0.0. - Versioning: Uses SemVer for releases, managed via
@jscutlery/semver. - License: MIT.
Sources: packages/gcp-storage/package.json:16-23, packages/gcp-storage/project.json:68-71
Related Components
Google Cloud Storage is also utilized by other plugins in the suite, notably @nx-extend/gcp-task-runner, which uses Storage as a remote cache for Nx tasks to improve CI/CD speed.
Sources: README.md:35-37, packages/gcp-task-runner/CHANGELOG.md:104-106
Summary
GCP Storage streamlines the deployment of static content from an Nx workspace to Google Cloud. By providing built-in support for Gzip and directory mapping, it reduces the complexity of maintaining custom deployment scripts for cloud-hosted applications.