Skip to content

Commit 4c1e5c1

Browse files
committed
refactor: optimize function naming in local CDN plugin
rename transform function to replaceJsImportPaths to improve code readability and semantics. The new name more clearly expresses the actual functionality of the function: replacing import paths in JS files.
1 parent ebf82ca commit 4c1e5c1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/build/vite-config/src/localCdnFile/localCdnPlugin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const defaultCopyConfig = {
2828
* @param {string} filename - 文件名
2929
* @returns {string} - 处理后的内容
3030
*/
31-
function transform(content, filename) {
31+
function replaceJsImportPaths(content, filename) {
3232
if (filename.endsWith('.js')) {
3333
const result = babelReplaceImportPathWithCertainFileName(content, filename, console)
3434
return result.code || content
@@ -144,7 +144,7 @@ async function copyFileOrDirectory(srcPath, destPaths, copiedFiles, outDir) {
144144
const content = await fs.readFile(file, 'utf-8')
145145

146146
// 应用转换
147-
const transformedContent = transform(content, file)
147+
const transformedContent = replaceJsImportPaths(content, file)
148148

149149
// 写入转换后的内容
150150
await fs.writeFile(destFilePath, transformedContent)
@@ -162,7 +162,7 @@ async function copyFileOrDirectory(srcPath, destPaths, copiedFiles, outDir) {
162162
const content = await fs.readFile(srcPath, 'utf-8')
163163

164164
// 应用转换
165-
const transformedContent = transform(content, srcPath)
165+
const transformedContent = replaceJsImportPaths(content, srcPath)
166166

167167
// 写入转换后的内容
168168
await fs.writeFile(finalDestPath, transformedContent)

0 commit comments

Comments
 (0)