# gcs-webpack-plugin

> A Webpack plugin to upload assets in Google Cloud Storage.

Latest version **0.9.2** (published 2020-01-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install gcs-webpack-plugin
pnpm add gcs-webpack-plugin
yarn add gcs-webpack-plugin
bun add gcs-webpack-plugin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.2 |
| Published | 2020-01-15 |
| First published | 2020-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 35.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 19 |
| Author | Anton Antonov |
| Maintainers | nisalvd |
| Keywords | assets, cloud, google, node, plugin, production, storage, upload, webpack |

## Links

- npm: https://www.npmjs.com/package/gcs-webpack-plugin
- Repository: https://github.com/syndbg/webpack-google-cloud-storage-plugin
- Homepage: https://github.com/syndbg/webpack-google-cloud-storage-plugin#readme
- Issues: https://github.com/syndbg/webpack-google-cloud-storage-plugin/issues
- npm.io page: https://npm.io/package/gcs-webpack-plugin

## Dependencies (6)

- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6
- [prop-types](https://npm.io/package/prop-types.md) ^0.2.0
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.0
- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.16.0
- [recursive-readdir](https://npm.io/package/recursive-readdir.md) ^2.1.0
- [@google-cloud/storage](https://npm.io/package/@google-cloud/storage.md) ^4.2.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.9.2 (latest) — 2020-01-15
- 0.9.1 — 2020-01-15
- 0.9.0 — 2020-01-15

## README

# webpack-google-cloud-storage-plugin

[![npm version](https://badge.fury.io/js/webpack-google-cloud-storage-plugin.svg)](https://badge.fury.io/js/webpack-google-cloud-storage-plugin)

A Webpack plugin to upload assets in Google Cloud Storage.

## Installation

`npm install --save webpack-google-cloud-storage-plugin`

## Usage

```JavaScript
// In your webpack.config.js
import WebpackGoogleCloudStoragePlugin from 'webpack-google-cloud-storage-plugin';

module.exports = {
  ...
  plugins: [
    new WebpackGoogleCloudStoragePlugin({
      directory: './src',
      // NOTE: Array of regexes matching filenames to include in the uploading process
      include: ['app.js'],
      // NOTE: Array of regexes matching filenames to exclude in the uploading process
      exclude: ['cats.js'],
      // NOTE: Options passed directly to Google cloud Node Storage client. This is 
      // mostly for authentication-wise. For more information:
      // https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/storage#authentication
      storageOptions: {
        // projectId is optional if you specify a keyFilename
        projectId: 'grape-spaceship-123',
        // keyFilename: '/path/to/keyfile.json'
        // keyFilename: './examples/my-credentials.json', // note: Filename, not FileName
        // key: 'mykey',
        // credentials: require('/path/to/credentials.json'),
      },
      // NOTE: Options used by
      // WebpackGoogleCloudStoragePlugin
      // regarding uploading.
      uploadOptions: {
        // Where to upload files
        bucketName: 'my-bucket-name',
        // NOTE: Prefix to add in the bucket file path.
        // E.g: app.js => assets/v1/app.js,
        // file is an object with { name:, path: }.
        destinationNameFn: file =>
           path.join('assets', file.path)
        ,
        // Available properties in returned object are defined here;
        // https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON
        // It will be passed into 'upload' here:
        // https://github.com/googleapis/nodejs-storage/blob/master/samples/files.js#L116
        metadataFn: file => ({
          // cache it a little longer!
          cacheControl: 'public, max-age=31536000',
        }),
        // Make gzip compressed (default: false)
        gzip: true,
        // Make file public (default: false)
        makePublic: true,
        // Resumable upload (default: true)
        // https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload
        resumable: true,
        // Concurrency ratio when uploading files (default: 10)
        concurrency: 5,
      },
    }),
  ],
};
```
## Examples

Check out the examples folder for a working demo.

Add your credentials to `storageOptions` and set `uploadOptions`.

Then you can run the demo webpack using `npm run example`.

---
_Source: https://npm.io/package/gcs-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
