# webpack-playcanvas-uploader

> A lightweight Webpack plugin to automatically upload your bundles to PlayCanvas.

Latest version **1.1.1** (published 2025-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install webpack-playcanvas-uploader
pnpm add webpack-playcanvas-uploader
yarn add webpack-playcanvas-uploader
bun add webpack-playcanvas-uploader
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2025-05-02 |
| First published | 2022-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steven Derks |
| Maintainers | thatstevenguy |
| Keywords | playcanvas, uploader, upload, webpack, webpackplugin, restapi, webgl, webgpu, gamedev, bundle |

## Links

- npm: https://www.npmjs.com/package/webpack-playcanvas-uploader
- Repository: https://github.com/ThatStevenGuy/webpack-playcanvas-uploader
- Issues: https://github.com/ThatStevenGuy/webpack-playcanvas-uploader/issues
- npm.io page: https://npm.io/package/webpack-playcanvas-uploader

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.9.0
- [form-data](https://npm.io/package/form-data.md) ^4.0.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2025-05-02
- 1.1.0 — 2024-04-22
- 1.0.3 — 2023-11-24
- 1.0.2 — 2022-07-22
- 1.0.1 — 2022-07-22
- 1.0.0 — 2022-07-22

## README

# PlayCanvas Uploader 🚀
[![npm version](https://img.shields.io/npm/v/webpack-playcanvas-uploader.svg)](https://www.npmjs.com/package/webpack-playcanvas-uploader)
[![license](https://img.shields.io/npm/l/webpack-playcanvas-uploader.svg)](LICENSE)
[![downloads](https://img.shields.io/npm/dm/webpack-playcanvas-uploader.svg)](https://www.npmjs.com/package/webpack-playcanvas-uploader)

A lightweight Webpack plugin to automatically upload your bundles to PlayCanvas.

ℹ️ Looking for the Rollup version? [rollup-plugin-playcanvas-uploader](https://www.npmjs.com/package/rollup-plugin-playcanvas-uploader)

## Installation
```
npm install webpack-playcanvas-uploader --save-dev
```

## Usage
Add the following to your `webpack.config.js`. Make sure to replace the placeholders with the correct values (see project details section below).

**CommonJS:**
```
const PlayCanvasUploader = require("webpack-playcanvas-uploader");

module.exports = {
    plugins: [
        new PlayCanvasUploader({
            projectId: yourProjectId,
            branchId: yourBranchId,
            accessToken: yourAccessToken,
            files: [
                { path: "main.js", assetId: yourScriptId }
            ]
        })
    ]
}
```

**ECMAScript:**
```
import PlayCanvasUploader from "webpack-playcanvas-uploader";

export default (env) => {
    return {
        plugins: [
            new PlayCanvasUploader({
                projectId: yourProjectId,
                branchId: yourBranchId,
                accessToken: yourAccessToken,
                files: [
                    { path: "main.js", assetId: yourScriptId }
                ]
            })
        ]
    }
};
```
## Retrieving Project Details
Follow these steps to retrieve your PlayCanvas project details. Use these to overwrite the placeholders in your uploader config (outlined above):
1. Create an empty script in your PlayCanvas project (e.g. `main.js`) and click on it to open the inspector. Copy the ID of the file (a numeric value at the top) and paste it under the `assetId` of the first file in your uploader config. Whenever you make a bundle using Webpack, the contents of your bundle will be uploaded to this script file. Make sure the path of the file (e.g. `main.js`) actually matches the path of the bundle created by Webpack. The uploader will search for the bundle in your Webpack's output directory, so there's no need to include the output directory itself in the file path.
2. Open your browser's console and enter `config.project.id`, `config.self.branch.id` and `config.accessToken`. Copy the values over to your uploader config as `projectId`, `branchId` and `accessToken` respectively. Make sure to read the security section below to help keep your access token secret.

You're all set! 🎉 PlayCanvas Uploader will now automatically upload your bundles.

## Security
⚠️ **Keep your access token secret!**

Do not commit it to Git. You can instead store it in a Git-ignored JSON file and import it into your `webpack.config.js`. Alternatively, you can add your access token as an environment variable and use `process.env` to access it (e.g. `process.env.PLAYCANVAS_ACCESS_TOKEN`).

## Bug Reports & Feature Requests
Bug reports and feature requests welcome — please open an issue on [GitHub](https://github.com/ThatStevenGuy/webpack-playcanvas-uploader/issues).

## License
MIT © 2025 Steven Derks  
Distributed under the MIT License. See the [LICENSE](https://github.com/ThatStevenGuy/webpack-playcanvas-uploader/blob/main/LICENSE) file for details.

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