vite-plugin-deploy-oss 3.4.2 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,24 +47,83 @@ Run build and deploy:
47
47
  DEPLOY_OSS=1 pnpm build
48
48
  ```
49
49
 
50
+ ## Direct Upload
51
+
52
+ If you only want to upload an existing directory, use the built-in CLI. This does not require Vite.
53
+
54
+ Create a config file:
55
+
56
+ ```js
57
+ // deploy-oss.config.mjs
58
+ import { defineDeployConfig } from 'vite-plugin-deploy-oss'
59
+
60
+ export default defineDeployConfig({
61
+ accessKeyId: process.env.OSS_ACCESS_KEY_ID || '',
62
+ accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET || '',
63
+ bucket: process.env.OSS_BUCKET || '',
64
+ region: process.env.OSS_REGION || '',
65
+
66
+ outDir: 'dist',
67
+ uploadDir: 'H5/demo/prod',
68
+ configBase: 'https://example.com/H5/demo/prod/',
69
+
70
+ manifest: true,
71
+ failOnError: true,
72
+ })
73
+ ```
74
+
75
+ Run it from package scripts:
76
+
77
+ ```json
78
+ {
79
+ "scripts": {
80
+ "deploy": "deploy-oss --config deploy-oss.config.mjs"
81
+ }
82
+ }
83
+ ```
84
+
85
+ Or run it with npx:
86
+
87
+ ```bash
88
+ npx vite-plugin-deploy-oss --config deploy-oss.config.mjs
89
+ ```
90
+
91
+ You can also call the upload API directly:
92
+
93
+ ```ts
94
+ import { deployOss } from 'vite-plugin-deploy-oss/deploy'
95
+
96
+ await deployOss({
97
+ accessKeyId: process.env.OSS_ACCESS_KEY_ID || '',
98
+ accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET || '',
99
+ bucket: process.env.OSS_BUCKET || '',
100
+ region: process.env.OSS_REGION || '',
101
+ outDir: 'dist',
102
+ uploadDir: 'H5/demo/prod',
103
+ })
104
+ ```
105
+
106
+ `configBase` only changes URLs written to the manifest in direct upload mode. If you need Vite output paths to use the same base, keep using the Vite plugin during build.
107
+
50
108
  ## Configuration
51
109
 
52
- | Option | Default | Description |
53
- | :--- | :--- | :--- |
54
- | `open` | `true` | Whether to enable upload. Recommended to control with environment variables. |
55
- | `accessKeyId` | - | OSS access key ID. |
56
- | `accessKeySecret` | - | OSS access key secret. |
57
- | `bucket` | - | OSS bucket name. |
58
- | `region` | - | OSS region, e.g., `oss-cn-beijing`. |
59
- | `uploadDir` | - | Target directory in OSS to upload files. |
60
- | `configBase` | - | Modifies Vite's asset base path synchronously. |
61
- | `skip` | `'**/index.html'` | Glob pattern for files to skip uploading. |
62
- | `overwrite` | `true` | Whether to overwrite existing files on OSS with the same name. |
63
- | `autoDelete` | `false` | Whether to delete local build files after successful upload. |
64
- | `manifest` | `false` | Whether to generate and upload a build manifest file. |
65
- | `failOnError` | `true` | Whether to abort the build process if upload fails. |
66
- | `debug` | `false` | Whether to output time cost information for debugging. |
67
- | `fancy` | `true` | Whether to display a styled terminal progress bar. |
110
+ | Option | Default | Description |
111
+ | :---------------- | :---------------- | :--------------------------------------------------------------------------- |
112
+ | `open` | `true` | Whether to enable upload. Recommended to control with environment variables. |
113
+ | `accessKeyId` | - | OSS access key ID. |
114
+ | `accessKeySecret` | - | OSS access key secret. |
115
+ | `bucket` | - | OSS bucket name. |
116
+ | `region` | - | OSS region, e.g., `oss-cn-beijing`. |
117
+ | `outDir` | `'dist'` | Local directory to upload when using CLI or direct API. |
118
+ | `uploadDir` | - | Target directory in OSS to upload files. |
119
+ | `configBase` | - | Modifies Vite's asset base path synchronously. |
120
+ | `skip` | `'**/index.html'` | Glob pattern for files to skip uploading. |
121
+ | `overwrite` | `true` | Whether to overwrite existing files on OSS with the same name. |
122
+ | `autoDelete` | `false` | Whether to delete local build files after successful upload. |
123
+ | `manifest` | `false` | Whether to generate and upload a build manifest file. |
124
+ | `failOnError` | `true` | Whether to abort the build process if upload fails. |
125
+ | `debug` | `false` | Whether to output time cost information for debugging. |
126
+ | `fancy` | `true` | Whether to display a styled terminal progress bar. |
68
127
 
69
128
  ## Important Behaviors
70
129
 
@@ -130,6 +189,33 @@ You can also run the playground command in the project:
130
189
  pnpm run build:test:debug
131
190
  ```
132
191
 
192
+ ## Local Upload Tests
193
+
194
+ The playground includes three upload test paths:
195
+
196
+ ```bash
197
+ # Vite plugin upload
198
+ pnpm run build:test:deploy
199
+
200
+ # Direct API upload
201
+ pnpm run deploy:test:api
202
+
203
+ # CLI upload
204
+ pnpm run deploy:test:cli
205
+ ```
206
+
207
+ All three commands use the same environment variables as the playground:
208
+
209
+ ```bash
210
+ zAccessKeyId=xxx
211
+ zAccessKeySecret=xxx
212
+ zBucket=xxx
213
+ zBucketAlias=https://example.com
214
+ ```
215
+
216
+ The direct API test uploads `playground/__dist__` to `/test/__direct-api__/`.
217
+ The CLI test uploads `playground/__dist__` to `/test/__direct-cli__/`.
218
+
133
219
  ## Notes
134
220
 
135
221
  - It is highly recommended to use environment variables instead of hardcoding sensitive credentials.