Skip to content

Commit

Permalink
chore: correct typo
Browse files Browse the repository at this point in the history
  • Loading branch information
SegaraRai committed Jul 22, 2021
1 parent 261913c commit a5f8e85
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Plugin } from '../plugin'
import { ResolvedConfig } from '../config'
import { cleanUrl } from '../utils'
import { FS_PREFIX } from '../constants'
import { PluginContext, RenderedChunk, OutputOptions } from 'rollup'
import { OutputOptions, PluginContext, RenderedChunk } from 'rollup'
import MagicString from 'magic-string'
import { createHash } from 'crypto'

Expand Down Expand Up @@ -185,7 +185,7 @@ export function getAssetFilename(
return assetHashToFilenameMap.get(config)?.get(hash)
}

function assetFileNameToFileName(
function assetFileNamesToFileName(
file: string,
contentHash: string,
content: string | Buffer,
Expand All @@ -194,6 +194,7 @@ function assetFileNameToFileName(
const basename = path.basename(file)

// placeholders for `assetFileNames`
// see https://rollupjs.org/guide/en/#outputassetfilenames for available placeholders
// `hash` is slightly different from the rollup's one
const extname = path.extname(basename)
const ext = extname.substr(1)
Expand Down Expand Up @@ -228,7 +229,6 @@ function assetFileNameToFileName(
throw new TypeError('assetFileNames must be a string or a function')
}

// see https://rollupjs.org/guide/en/#outputassetfilenames for available placeholders
const fileName = assetFileNames.replace(
/\[\w+\]/g,
(placeholder: string): string => {
Expand Down Expand Up @@ -297,7 +297,12 @@ async function fileToBuiltUrl(
const contentHash = getAssetHash(content)
const { search, hash } = parseUrl(id)
const postfix = (search || '') + (hash || '')
const fileName = assetFileNameToFileName(file, contentHash, content, config)
const fileName = assetFileNamesToFileName(
file,
contentHash,
content,
config
)
if (!map.has(contentHash)) {
map.set(contentHash, fileName)
}
Expand Down

0 comments on commit a5f8e85

Please sign in to comment.