@yidun/cdn-upload-webpack-plugin 1.1.7 → 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 +7 -24
package/package.json
CHANGED
package/src/vite.js
CHANGED
|
@@ -85,25 +85,17 @@ function CdnUploadVitePlugin (options) {
|
|
|
85
85
|
filesToUpload = files.filter((_, index) => uploadFlags[index])
|
|
86
86
|
const skippedCount = files.length - filesToUpload.length
|
|
87
87
|
const precheckCost = Date.now() - precheckStart
|
|
88
|
-
console.log(`CdnUploadVitePlugin: precheck done
|
|
89
|
-
if (skippedCount > 0) {
|
|
90
|
-
console.log(`CdnUploadVitePlugin: skip upload ${skippedCount} hashed files already on CDN`)
|
|
91
|
-
}
|
|
88
|
+
console.log(`CdnUploadVitePlugin: precheck done — total=${files.length}, upload=${filesToUpload.length}, skipped=${skippedCount}, cost=${precheckCost}ms`)
|
|
92
89
|
}
|
|
93
90
|
if (filesToUpload.length === 0) {
|
|
94
|
-
if (cleanupAfterUpload)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const totalCost = Date.now() - uploadStageStart
|
|
99
|
-
console.log(`CdnUploadVitePlugin: no files need upload, total upload stage cost=${totalCost}ms`)
|
|
100
|
-
if (buildStartAt > 0) {
|
|
101
|
-
console.log(`CdnUploadVitePlugin: build+upload total cost=${Date.now() - buildStartAt}ms`)
|
|
102
|
-
}
|
|
91
|
+
if (cleanupAfterUpload) cleanupFiles(dirs, cleanupKeepRules)
|
|
92
|
+
const buildCost = buildStartAt > 0 ? `, build+upload=${Date.now() - buildStartAt}ms` : ''
|
|
93
|
+
console.log(`CdnUploadVitePlugin: done — no files to upload, total=${Date.now() - uploadStageStart}ms${buildCost}${cleanupAfterUpload ? ' [cleaned]' : ''}`)
|
|
103
94
|
return
|
|
104
95
|
}
|
|
105
96
|
const tasks = filesToUpload.map((file) => new NosUploadTask(client, file))
|
|
106
97
|
const uploadStart = Date.now()
|
|
98
|
+
console.log('CdnUploadVitePlugin: assets uploading ...')
|
|
107
99
|
return new Promise((resolve, reject) => {
|
|
108
100
|
const taskDispatcher = new TaskDispatcher(tasks, {
|
|
109
101
|
onSuccess: async (task) => {
|
|
@@ -111,19 +103,10 @@ function CdnUploadVitePlugin (options) {
|
|
|
111
103
|
const { _file, _namespace } = task?.[0] || {}
|
|
112
104
|
const data = await fetch(`${domain}/${_namespace}/${_file.relative}`)
|
|
113
105
|
if (!data.ok || data.status !== 200) {
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
if (cleanupAfterUpload) {
|
|
117
|
-
cleanupFiles(dirs, cleanupKeepRules)
|
|
118
|
-
console.log('CdnUploadVitePlugin: local static assets cleaned')
|
|
119
|
-
}
|
|
120
|
-
const uploadCost = Date.now() - uploadStart
|
|
121
|
-
const totalCost = Date.now() - uploadStageStart
|
|
122
|
-
console.log(`CdnUploadVitePlugin: upload cost=${uploadCost}ms, total upload stage cost=${totalCost}ms`)
|
|
123
|
-
if (buildStartAt > 0) {
|
|
124
|
-
console.log(`CdnUploadVitePlugin: build+upload total cost=${Date.now() - buildStartAt}ms`)
|
|
106
|
+
reject(new Error(`CdnUploadVitePlugin Error: url: ${data.url}, status: ${data.status}`))
|
|
125
107
|
}
|
|
126
108
|
console.log('CdnUploadVitePlugin: assets upload success')
|
|
109
|
+
if (cleanupAfterUpload) cleanupFiles(dirs, cleanupKeepRules)
|
|
127
110
|
resolve()
|
|
128
111
|
},
|
|
129
112
|
onError: (error) => reject(error)
|