Skip to content

Commit

Permalink
perf: minify css only when needed (#5178)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Oct 23, 2021
1 parent 61b4b39 commit 7970239
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -311,15 +311,15 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
// record css
if (!inlined) {
styles.set(id, css)
} else {
css = await minifyCSS(css, config)
}

return {
code:
modulesCode ||
(usedRE.test(id)
? `export default ${JSON.stringify(css)}`
? `export default ${JSON.stringify(
inlined ? await minifyCSS(css, config) : css
)}`
: `export default ''`),
map: { mappings: '' },
// avoid the css module from being tree-shaken so that we can retrieve
Expand Down

0 comments on commit 7970239

Please sign in to comment.