Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: minify css only when needed #5178

Merged
merged 4 commits into from Oct 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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