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.
Files changed (2) hide show
  1. package/README.md +50 -46
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,16 +1,20 @@
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
+
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` | `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` 只影响清单里生成的访问地址,不会改变实际上传路径。
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
- 开启 `debug` 后,构建结束会额外输出关键步骤耗时,方便判断慢在哪里。
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
- 也可以使用项目内的 playground 命令:
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
- - 建议生产发布时保持 `failOnError: true`,避免部分文件没上传却继续完成流程。
133
- - 如果开启 `autoDelete`,请确认不需要保留本地构建文件。
134
- - 当前版本仅支持 ESM,也就是 `import` 用法,不提供 `require` 入口。
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.0",
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": "将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",