Skip to content

Commit

Permalink
fix: ensure new caches for vite:css-post
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 24, 2021
1 parent 3eecc6f commit 1ba59fb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,24 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
* Plugin applied after user plugins
*/
export function cssPostPlugin(config: ResolvedConfig): Plugin {
const styles = new Map<string, string>()
const pureCssChunks = new Set<string>()
let styles: Map<string, string>
let pureCssChunks: Set<string>

// when there are multiple rollup outputs and extracting CSS, only emit once,
// since output formats have no effect on the generated CSS.
const outputToExtractedCSSMap = new Map<NormalizedOutputOptions, string>()
let outputToExtractedCSSMap: Map<NormalizedOutputOptions, string>
let hasEmitted = false

return {
name: 'vite:css-post',

buildStart() {
// Ensure new caches for every build (i.e. rebuilding in watch mode)
styles = new Map<string, string>()
pureCssChunks = new Set<string>()
outputToExtractedCSSMap = new Map<NormalizedOutputOptions, string>()
},

transform(css, id, ssr) {
if (!cssLangRE.test(id) || commonjsProxyRE.test(id)) {
return
Expand Down

0 comments on commit 1ba59fb

Please sign in to comment.