vite-plugin-deploy-oss 3.4.0 → 3.4.1
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 +88 -46
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
# vite-plugin-deploy-oss
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
4
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
5
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Upload Vite build artifacts to Aliyun OSS.
|
|
8
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
9
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
10
|
+
[](https://www.npmjs.com/package/vite-plugin-deploy-oss)
|
|
11
|
+
|
|
12
|
+
Upload Vite build artifacts to Aliyun OSS.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
6
17
|
|
|
7
18
|
```bash
|
|
8
19
|
pnpm add vite-plugin-deploy-oss -D
|
|
9
20
|
```
|
|
10
21
|
|
|
11
|
-
##
|
|
22
|
+
## Quick Start
|
|
12
23
|
|
|
13
|
-
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
It is recommended to control the deployment using environment variables to avoid accidental uploads during local builds.
|
|
27
|
+
It is recommended to control the deployment using environment variables to avoid accidental uploads during local builds.
|
|
14
28
|
|
|
15
29
|
```ts
|
|
16
30
|
// vite.config.ts
|
|
@@ -37,63 +51,80 @@ export default defineConfig({
|
|
|
37
51
|
})
|
|
38
52
|
```
|
|
39
53
|
|
|
40
|
-
|
|
54
|
+
Run build and deploy:
|
|
55
|
+
Run build and deploy:
|
|
41
56
|
|
|
42
57
|
```bash
|
|
43
58
|
DEPLOY_OSS=1 pnpm build
|
|
44
59
|
```
|
|
45
60
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
- `
|
|
70
|
-
- `
|
|
71
|
-
- `
|
|
72
|
-
- `
|
|
61
|
+
## Configuration
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
| Option | Default | Description |
|
|
66
|
+
| :---------------- | :---------------- | :--------------------------------------------------------------------------- |
|
|
67
|
+
| `open` | `true` | Whether to enable upload. Recommended to control with environment variables. |
|
|
68
|
+
| `accessKeyId` | - | OSS access key ID. |
|
|
69
|
+
| `accessKeySecret` | - | OSS access key secret. |
|
|
70
|
+
| `bucket` | - | OSS bucket name. |
|
|
71
|
+
| `region` | - | OSS region, e.g., `oss-cn-beijing`. |
|
|
72
|
+
| `uploadDir` | - | Target directory in OSS to upload files. |
|
|
73
|
+
| `configBase` | - | Modifies Vite's asset base path synchronously. |
|
|
74
|
+
| `skip` | `'**/index.html'` | Glob pattern for files to skip uploading. |
|
|
75
|
+
| `overwrite` | `true` | Whether to overwrite existing files on OSS with the same name. |
|
|
76
|
+
| `autoDelete` | `false` | Whether to delete local build files after successful upload. |
|
|
77
|
+
| `manifest` | `false` | Whether to generate and upload a build manifest file. |
|
|
78
|
+
| `failOnError` | `true` | Whether to abort the build process if upload fails. |
|
|
79
|
+
| `debug` | `false` | Whether to output time cost information for debugging. |
|
|
80
|
+
| `fancy` | `true` | Whether to display a styled terminal progress bar. |
|
|
81
|
+
|
|
82
|
+
## Important Behaviors
|
|
83
|
+
|
|
84
|
+
- If `open: true` and any of the required options (`accessKeyId`, `accessKeySecret`, `bucket`, `region`, or `uploadDir`) are missing, the build process will fail and terminate.
|
|
85
|
+
- When `manifest` is enabled, all built files are uploaded automatically, and local build files are retained.
|
|
86
|
+
- When `manifest` is enabled, `skip` defaults to an empty array and `autoDelete` is forced to `false`.
|
|
87
|
+
- `oss-manifest.json` only tracks successfully uploaded files in the current build and does not include the manifest file itself.
|
|
88
|
+
- `configBase` affects both Vite's output asset paths and the URL addresses inside the manifest.
|
|
89
|
+
- `alias` only affects the URLs generated inside the manifest; it does not change the actual upload destination on OSS.
|
|
90
|
+
|
|
91
|
+
## Important Behaviors
|
|
92
|
+
|
|
93
|
+
- If `open: true` and any of the required options (`accessKeyId`, `accessKeySecret`, `bucket`, `region`, or `uploadDir`) are missing, the build process will fail and terminate.
|
|
94
|
+
- When `manifest` is enabled, all built files are uploaded automatically, and local build files are retained.
|
|
95
|
+
- When `manifest` is enabled, `skip` defaults to an empty array and `autoDelete` is forced to `false`.
|
|
96
|
+
- `oss-manifest.json` only tracks successfully uploaded files in the current build and does not include the manifest file itself.
|
|
97
|
+
- `configBase` affects both Vite's output asset paths and the URL addresses inside the manifest.
|
|
98
|
+
- `alias` only affects the URLs generated inside the manifest; it does not change the actual upload destination on OSS.
|
|
73
99
|
|
|
74
100
|
## Manifest
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
Enable manifest:
|
|
103
|
+
Enable manifest:
|
|
77
104
|
|
|
78
105
|
```ts
|
|
79
106
|
vitePluginDeployOss({
|
|
80
|
-
//
|
|
107
|
+
// ...other options
|
|
108
|
+
// ...other options
|
|
81
109
|
manifest: true,
|
|
82
110
|
})
|
|
83
111
|
```
|
|
84
112
|
|
|
85
|
-
|
|
113
|
+
Customize manifest filename:
|
|
114
|
+
Customize manifest filename:
|
|
86
115
|
|
|
87
116
|
```ts
|
|
88
117
|
vitePluginDeployOss({
|
|
89
|
-
//
|
|
118
|
+
// ...other options
|
|
119
|
+
// ...other options
|
|
90
120
|
manifest: {
|
|
91
121
|
fileName: 'meta/oss-manifest.json',
|
|
92
122
|
},
|
|
93
123
|
})
|
|
94
124
|
```
|
|
95
125
|
|
|
96
|
-
|
|
126
|
+
Manifest JSON example:
|
|
127
|
+
Manifest JSON example:
|
|
97
128
|
|
|
98
129
|
```json
|
|
99
130
|
{
|
|
@@ -109,26 +140,37 @@ vitePluginDeployOss({
|
|
|
109
140
|
}
|
|
110
141
|
```
|
|
111
142
|
|
|
112
|
-
##
|
|
143
|
+
## Debugging
|
|
144
|
+
|
|
145
|
+
## Debugging
|
|
113
146
|
|
|
114
|
-
|
|
147
|
+
Enable `debug` to log the time taken for each key step during deployment, which helps locate bottlenecks:
|
|
148
|
+
Enable `debug` to log the time taken for each key step during deployment, which helps locate bottlenecks:
|
|
115
149
|
|
|
116
150
|
```ts
|
|
117
151
|
vitePluginDeployOss({
|
|
118
|
-
//
|
|
152
|
+
// ...other options
|
|
153
|
+
// ...other options
|
|
119
154
|
debug: process.env.DEPLOY_OSS_DEBUG === '1',
|
|
120
155
|
})
|
|
121
156
|
```
|
|
122
157
|
|
|
123
|
-
|
|
158
|
+
You can also run the playground command in the project:
|
|
159
|
+
You can also run the playground command in the project:
|
|
124
160
|
|
|
125
161
|
```bash
|
|
126
162
|
pnpm run build:test:debug
|
|
127
163
|
```
|
|
128
164
|
|
|
129
|
-
##
|
|
165
|
+
## Notes
|
|
166
|
+
|
|
167
|
+
## Notes
|
|
130
168
|
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
169
|
+
- It is highly recommended to use environment variables instead of hardcoding sensitive credentials.
|
|
170
|
+
- Keep `failOnError: true` for production builds to avoid completing the build/deployment pipeline when some files failed to upload.
|
|
171
|
+
- Make sure you do not need the local build directory before enabling `autoDelete`.
|
|
172
|
+
- The current version only supports ESM (`import` syntax). CommonJS (`require`) is not supported.
|
|
173
|
+
- It is highly recommended to use environment variables instead of hardcoding sensitive credentials.
|
|
174
|
+
- Keep `failOnError: true` for production builds to avoid completing the build/deployment pipeline when some files failed to upload.
|
|
175
|
+
- Make sure you do not need the local build directory before enabling `autoDelete`.
|
|
176
|
+
- The current version only supports ESM (`import` syntax). CommonJS (`require`) is not supported.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-deploy-oss",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"author": "yulinzhao",
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"description": "
|
|
32
|
+
"description": "Upload Vite build artifacts to Aliyun OSS.",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/ali-oss": "^6.23.3",
|
|
35
35
|
"@types/node": "^22.19.19",
|