Skip to content

Commit

Permalink
fix: css build path
Browse files Browse the repository at this point in the history
  • Loading branch information
jessarcher committed Jun 10, 2022
1 parent fabc52b commit 3147b88
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -47,6 +47,7 @@ import {
import type { Logger } from '../logger'
import { addToHTMLProxyTransformResult } from './html'
import {
assetFileNamesToFileName,
assetUrlRE,
checkPublicFile,
fileToUrl,
Expand Down Expand Up @@ -512,9 +513,24 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName)
chunkCSS = await finalizeCss(chunkCSS, true, config)

const output = config.build?.rollupOptions?.output
const assetFileNames =
(output && !Array.isArray(output)
? output.assetFileNames
: undefined) ??
// defaults to '<assetsDir>/[name].[hash][extname]'
// slightly different from rollup's one ('assets/[name]-[hash][extname]')
path.posix.join(config.build.assetsDir, '[name].[hash][extname]')

// emit corresponding css file
const fileHandle = this.emitFile({
name: cssAssetName,
fileName: assetFileNamesToFileName(
assetFileNames,
cssAssetName,
getHash(chunkCSS),
chunkCSS
),
type: 'asset',
source: chunkCSS
})
Expand Down

0 comments on commit 3147b88

Please sign in to comment.