The plugin currently only supports
rsyncandoss-upload-tool. If it is rsync, you need to confirm whether the environment supports rsync.
Using npm:
npm install @planjs/webpack-deploy-plugin --save-devUsing yarn:
yarn add @planjs/webpack-deploy-plugin -Dwebpack.Stats All output content will be uploaded to the server, or oss.
webpack.config.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'
})
]
};Upload configuration collection.
Type: Record<any, TargetItem> | TargetItem
If there are multiple upload configurations, it will be switched according to this as the key.
Type: string
Type: rsync | oss
How to upload files.
Upload to server folder.
type ossfolder default''
type rsyncserver connection string[email protected]:/www/deploy folder
Type: string
Type: string | string[] multimatch
Paths based on compilation.assets or output folder matching will be uploaded.
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.
Rsync args.
Type: { args: string[][] }
eg:
['bwlimit', 10]rsync
Type: object
Detailed reference oss-upload-tool
It also supports related environment variable configuration.
Type: number
Maximum number of failed retries.
Only valid for oss-upload-tool, rsync does not need to retry.
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.
Type: boolean
Default: false only compilation.assets files
Whether to upload the output directory completely.
Type: (stats: Stats, shelljs) => void | Promise<void>
Before upload event.
Type: (stats: Stats, shelljs) => void | Promise<void>
Upload complete event.
Type: string[][] | string[]
before Upload start exec script.
Detailed reference execa
Type: string[][] | string[]
before Upload finish exec script.
Detailed reference execa
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.
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.
MIT © fupengl