Skip to content

Commit

Permalink
chore: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 17, 2022
1 parent 46c15af commit 7629352
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -300,7 +300,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
? rollupOptionsOutput[0]
: rollupOptionsOutput
)?.assetFileNames
const getCssAssetsDir = (cssAssetName: string) => {
const getCssAssetDirname = (cssAssetName: string) => {
if (!assetFileNames) {
return config.build.assetsDir
} else if (typeof assetFileNames === 'string') {
Expand Down Expand Up @@ -452,8 +452,8 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {

// resolve asset URL placeholders to their built file URLs
function resolveAssetUrlsInCss(chunkCSS: string, cssAssetName: string) {
const cssAssetsDir = relativeBase
? getCssAssetsDir(cssAssetName)
const cssAssetDirname = relativeBase
? getCssAssetDirname(cssAssetName)
: undefined

// replace asset url references with resolved url.
Expand All @@ -462,7 +462,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
chunk.viteMetadata.importedAssets.add(cleanUrl(filename))
if (relativeBase) {
// relative base + extracted CSS
const relativePath = path.relative(cssAssetsDir!, filename)
const relativePath = path.relative(cssAssetDirname!, filename)
return relativePath.startsWith('.')
? relativePath
: './' + relativePath
Expand All @@ -473,7 +473,10 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
})
// resolve public URL from CSS paths
if (relativeBase) {
const relativePathToPublicFromCSS = path.relative(cssAssetsDir!, '')
const relativePathToPublicFromCSS = path.relative(
cssAssetDirname!,
''
)
chunkCSS = chunkCSS.replace(
publicAssetUrlRE,
(_, hash) =>
Expand Down

0 comments on commit 7629352

Please sign in to comment.