@yidun/cdn-upload-webpack-plugin 1.1.8 → 1.1.9
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/package.json +1 -1
- package/src/.claude/settings.local.json +7 -0
- package/src/vite.js +10 -4
package/package.json
CHANGED
package/src/vite.js
CHANGED
|
@@ -95,17 +95,23 @@ function CdnUploadVitePlugin (options) {
|
|
|
95
95
|
}
|
|
96
96
|
const tasks = filesToUpload.map((file) => new NosUploadTask(client, file))
|
|
97
97
|
const uploadStart = Date.now()
|
|
98
|
-
console.log(
|
|
98
|
+
console.log('CdnUploadVitePlugin: assets uploading ...')
|
|
99
99
|
return new Promise((resolve, reject) => {
|
|
100
100
|
const taskDispatcher = new TaskDispatcher(tasks, {
|
|
101
|
-
onSuccess: () => {
|
|
101
|
+
onSuccess: async (task) => {
|
|
102
|
+
// cdn 上传成功后健康检查
|
|
103
|
+
const { _file, _namespace } = task?.[0] || {}
|
|
104
|
+
const data = await fetch(`${domain}/${_namespace}/${_file.relative}`)
|
|
105
|
+
if (!data.ok || data.status !== 200) {
|
|
106
|
+
reject(new Error(`CdnUploadVitePlugin Error: url: ${data.url}, status: ${data.status}`))
|
|
107
|
+
}
|
|
108
|
+
console.log('CdnUploadVitePlugin: assets upload success')
|
|
102
109
|
if (cleanupAfterUpload) cleanupFiles(dirs, cleanupKeepRules)
|
|
103
|
-
const buildCost = buildStartAt > 0 ? `, build+upload=${Date.now() - buildStartAt}ms` : ''
|
|
104
|
-
console.log(`CdnUploadVitePlugin: done — upload=${Date.now() - uploadStart}ms, total=${Date.now() - uploadStageStart}ms${buildCost}${cleanupAfterUpload ? ' [cleaned]' : ''}`)
|
|
105
110
|
resolve()
|
|
106
111
|
},
|
|
107
112
|
onError: (error) => reject(error)
|
|
108
113
|
})
|
|
114
|
+
console.log('CdnUploadVitePlugin: assets uploading ...')
|
|
109
115
|
taskDispatcher.dispatch(parallelCount)
|
|
110
116
|
})
|
|
111
117
|
}
|