vite-plugin-deploy-oss 3.4.0 → 3.4.2
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 +50 -46
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
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
|
+
|
|
9
|
+
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
12
|
pnpm add vite-plugin-deploy-oss -D
|
|
9
13
|
```
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## Quick Start
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
It is recommended to control the deployment using environment variables to avoid accidental uploads during local builds.
|
|
14
18
|
|
|
15
19
|
```ts
|
|
16
20
|
// vite.config.ts
|
|
@@ -37,63 +41,63 @@ export default defineConfig({
|
|
|
37
41
|
})
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
Run build and deploy:
|
|
41
45
|
|
|
42
46
|
```bash
|
|
43
47
|
DEPLOY_OSS=1 pnpm build
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
| `open`
|
|
51
|
-
| `accessKeyId`
|
|
52
|
-
| `accessKeySecret` | -
|
|
53
|
-
| `bucket`
|
|
54
|
-
| `region`
|
|
55
|
-
| `uploadDir`
|
|
56
|
-
| `configBase`
|
|
57
|
-
| `skip`
|
|
58
|
-
| `overwrite`
|
|
59
|
-
| `autoDelete`
|
|
60
|
-
| `manifest`
|
|
61
|
-
| `failOnError`
|
|
62
|
-
| `debug`
|
|
63
|
-
| `fancy`
|
|
64
|
-
|
|
65
|
-
##
|
|
66
|
-
|
|
67
|
-
- `open: true`
|
|
68
|
-
- `manifest`
|
|
69
|
-
- `manifest`
|
|
70
|
-
- `oss-manifest.json`
|
|
71
|
-
- `configBase`
|
|
72
|
-
- `alias`
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
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. |
|
|
68
|
+
|
|
69
|
+
## Important Behaviors
|
|
70
|
+
|
|
71
|
+
- If `open: true` and any of the required options (`accessKeyId`, `accessKeySecret`, `bucket`, `region`, or `uploadDir`) are missing, the build process will fail and terminate.
|
|
72
|
+
- When `manifest` is enabled, all built files are uploaded automatically, and local build files are retained.
|
|
73
|
+
- When `manifest` is enabled, `skip` defaults to an empty array and `autoDelete` is forced to `false`.
|
|
74
|
+
- `oss-manifest.json` only tracks successfully uploaded files in the current build and does not include the manifest file itself.
|
|
75
|
+
- `configBase` affects both Vite's output asset paths and the URL addresses inside the manifest.
|
|
76
|
+
- `alias` only affects the URLs generated inside the manifest; it does not change the actual upload destination on OSS.
|
|
73
77
|
|
|
74
78
|
## Manifest
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
Enable manifest:
|
|
77
81
|
|
|
78
82
|
```ts
|
|
79
83
|
vitePluginDeployOss({
|
|
80
|
-
//
|
|
84
|
+
// ...other options
|
|
81
85
|
manifest: true,
|
|
82
86
|
})
|
|
83
87
|
```
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
Customize manifest filename:
|
|
86
90
|
|
|
87
91
|
```ts
|
|
88
92
|
vitePluginDeployOss({
|
|
89
|
-
//
|
|
93
|
+
// ...other options
|
|
90
94
|
manifest: {
|
|
91
95
|
fileName: 'meta/oss-manifest.json',
|
|
92
96
|
},
|
|
93
97
|
})
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
Manifest JSON example:
|
|
97
101
|
|
|
98
102
|
```json
|
|
99
103
|
{
|
|
@@ -109,26 +113,26 @@ vitePluginDeployOss({
|
|
|
109
113
|
}
|
|
110
114
|
```
|
|
111
115
|
|
|
112
|
-
##
|
|
116
|
+
## Debugging
|
|
113
117
|
|
|
114
|
-
|
|
118
|
+
Enable `debug` to log the time taken for each key step during deployment, which helps locate bottlenecks:
|
|
115
119
|
|
|
116
120
|
```ts
|
|
117
121
|
vitePluginDeployOss({
|
|
118
|
-
//
|
|
122
|
+
// ...other options
|
|
119
123
|
debug: process.env.DEPLOY_OSS_DEBUG === '1',
|
|
120
124
|
})
|
|
121
125
|
```
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
You can also run the playground command in the project:
|
|
124
128
|
|
|
125
129
|
```bash
|
|
126
130
|
pnpm run build:test:debug
|
|
127
131
|
```
|
|
128
132
|
|
|
129
|
-
##
|
|
133
|
+
## Notes
|
|
130
134
|
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
+
- It is highly recommended to use environment variables instead of hardcoding sensitive credentials.
|
|
136
|
+
- Keep `failOnError: true` for production builds to avoid completing the build/deployment pipeline when some files failed to upload.
|
|
137
|
+
- Make sure you do not need the local build directory before enabling `autoDelete`.
|
|
138
|
+
- 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.2",
|
|
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",
|