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.
Files changed (2) hide show
  1. package/README.md +88 -46
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,16 +1,30 @@
1
1
  # vite-plugin-deploy-oss
2
2
 
3
- Vite 打包后的文件上传到阿里云 OSS。
3
+ [![npm version](https://img.shields.io/npm/v/vite-plugin-deploy-oss.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-deploy-oss)
4
+ [![npm downloads](https://img.shields.io/npm/dm/vite-plugin-deploy-oss.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-deploy-oss)
5
+ [![npm license](https://img.shields.io/npm/l/vite-plugin-deploy-oss.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-deploy-oss)
4
6
 
5
- ## 安装
7
+ Upload Vite build artifacts to Aliyun OSS.
8
+ [![npm version](https://img.shields.io/npm/v/vite-plugin-deploy-oss.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-deploy-oss)
9
+ [![npm downloads](https://img.shields.io/npm/dm/vite-plugin-deploy-oss.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-deploy-oss)
10
+ [![npm license](https://img.shields.io/npm/l/vite-plugin-deploy-oss.svg?style=flat-square)](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
- | `open` | `true` | 是否开启上传。建议用环境变量控制。 |
51
- | `accessKeyId` | - | OSS 访问密钥。 |
52
- | `accessKeySecret` | - | OSS 访问密钥。 |
53
- | `bucket` | - | OSS bucket 名称。 |
54
- | `region` | - | OSS 区域,例如 `oss-cn-beijing`。 |
55
- | `uploadDir` | - | 文件上传到 OSS 的目标目录。 |
56
- | `configBase` | - | 同步修改 Vite 的资源访问路径。 |
57
- | `skip` | `'**/index.html'` | 不上传的文件规则。 |
58
- | `overwrite` | `true` | 是否允许覆盖远端同名文件。 |
59
- | `autoDelete` | `false` | 上传成功后是否删除本地构建文件。 |
60
- | `manifest` | `false` | 是否生成并上传文件清单。 |
61
- | `failOnError` | `true` | 上传失败时是否中断构建。 |
62
- | `debug` | `false` | 是否输出耗时信息。 |
63
- | `fancy` | `true` | 是否显示更友好的终端进度。 |
64
-
65
- ## 重要行为
66
-
67
- - `open: true` 时,如果缺少 `accessKeyId`、`accessKeySecret`、`bucket`、`region` 或 `uploadDir`,会直接中断构建。
68
- - `manifest` 开启后,会自动上传全部文件,并自动保留本地构建文件。
69
- - `manifest` 开启后,`skip` 会按空数组处理,`autoDelete` 会按 `false` 处理。
70
- - `oss-manifest.json` 只记录本次成功上传的文件,不包含清单文件自身。
71
- - `configBase` 会影响 Vite 打包后的资源路径,也会影响清单里的访问地址。
72
- - `alias` 只影响清单里生成的访问地址,不会改变实际上传路径。
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
- 开启 `debug` 后,构建结束会额外输出关键步骤耗时,方便判断慢在哪里。
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
- 也可以使用项目内的 playground 命令:
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
- - 建议生产发布时保持 `failOnError: true`,避免部分文件没上传却继续完成流程。
133
- - 如果开启 `autoDelete`,请确认不需要保留本地构建文件。
134
- - 当前版本仅支持 ESM,也就是 `import` 用法,不提供 `require` 入口。
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.0",
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": "将dist目录下的文件上传到阿里云oss",
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",