Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/planjs/webpack-deploy-plugin
The webpack plugin handles various uploads of front-end files
https://github.com/planjs/webpack-deploy-plugin
deploy oss rsync webpack-plugin
Last synced: 23 days ago
JSON representation
The webpack plugin handles various uploads of front-end files
- Host: GitHub
- URL: https://github.com/planjs/webpack-deploy-plugin
- Owner: planjs
- Created: 2022-03-13T13:26:39.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T05:07:58.000Z (3 months ago)
- Last Synced: 2024-11-20T14:26:45.268Z (about 1 month ago)
- Topics: deploy, oss, rsync, webpack-plugin
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@planjs/webpack-deploy-plugin
- Size: 1.1 MB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# webpack-deploy-plugin
![npm](https://img.shields.io/npm/v/@planjs/webpack-deploy-plugin?label=latest)
[![test](https://github.com/planjs/webpack-deploy-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/planjs/webpack-deploy-plugin/actions/workflows/test.yml)> The plugin currently only supports `rsync` and `oss-upload-tool`. If it is rsync, you need to confirm whether the environment supports rsync.
## Install
Using npm:
```console
npm install @planjs/webpack-deploy-plugin --save-dev
```Using yarn:
```console
yarn add @planjs/webpack-deploy-plugin -D
```## Usage
`webpack.Stats` All output content will be uploaded to the server, or oss.
**webpack.config.js**
```js
const WebpackDeployPlugin = require('@planjs/webpack-deploy-plugin')module.exports = {
plugins: [
new WebpackDeployPlugin({
targets: {
oss: {
type: 'oss',
// oss deploy folder
dest: '/app/test1/',
patterns: ['**', '!**.js.map'],
OSSUploadOptions: {
type: 'COS',
COSOptions: {
SecretId: 'xxx',
SecretKey: 'xxx'
},
uploadParams: {
Bucket: 'xxx',
Region: 'xxx'
}
}
},
rsync: {
type: 'rsync',
patterns: ['**', '!**.js.map'],
dest: '[email protected]:/www/deploy folder'
}
},
// The key of the `targets` used
env: 'oss'
})
]
};
```## Options
### `targets`
Upload configuration collection.
Type: `Record | TargetItem`### `env`
If there are multiple upload configurations, it will be switched according to this as the key.
Type: `string`## TargetItem
### `type`
Type: `rsync | oss`
How to upload files.### `dest`
Upload to server folder.
> `type oss` folder default `''`
> `type rsync` server connection string `[email protected]:/www/deploy folder`Type: `string`
### `patterns`
Type: `string | string[]` [multimatch](https://www.npmjs.com/package/multimatch)
Paths based on `compilation.assets` or `output` folder matching will be uploaded.### `isUploadOutputDir`
Type: `boolean`
Default: `false`
By default, the file of `compilation.assets` is used, and when it is turned on, all the output folders will be uploaded.### `rsyncOptions`
Rsync args.
Type: `{ args: string[][] }`
> eg: `['bwlimit', 10]` [rsync](https://linux.die.net/man/1/rsync)### `OSSUploadOptions`
Type: `object`
> Detailed reference [oss-upload-tool](https://github.com/planjs/stan/tree/master/packages/oss-upload-tool)
> It also supports related environment variable configuration.### `maxAttempts`
Type: `number`
Maximum number of failed retries.
Only valid for `oss-upload-tool`, `rsync` does not need to retry.### `timeout`
Type: `number`
Execution timeout.
If it is `rsync`, it is the timeout period for executing the command. If it is `oss-upload-tool`, it is the single file upload timeout period.### isUploadOutputDir
Type: `boolean`
Default: false only `compilation.assets` files
Whether to upload the output directory completely.### `onUploadStart`
Type: `(stats: Stats, shelljs) => void | Promise`
Before upload event.### `onUploadFinish`
Type: `(stats: Stats, shelljs) => void | Promise`
Upload complete event.### `execUploadStartScripts`
Type: `string[][] | string[]`
before Upload start exec script.
> Detailed reference [execa](https://github.com/sindresorhus/execa)### `execUploadFinishScripts`
Type: `string[][] | string[]`
before Upload finish exec script.
> Detailed reference [execa](https://github.com/sindresorhus/execa)## FQA
### Window Rsync error: `The command line is too long`
By default, window will use 8191 as the longest length, leave 100 for other parameters, and if the remaining length is too long, it will become multiple rsync commands.
If it still fails, it may be an environment problem, change the cutting rules through the variable `MAX_COMMAND_LINE_LIMIT`.### Not all output directory contents are copied
By default, only the files on `compilation.assets` after webpack compilation will be copied. If you add files by other means, you can set isUploadOutputDir,
and the files in the entire output directory will be uploaded, and you can specify file upload through `patterns`.## License
MIT © [fupengl](https://github.com/fupengl)