Skip to content

Commit

Permalink
fix(css): do not include css string in bundle if not needed
Browse files Browse the repository at this point in the history
instead of 3e3c203
  • Loading branch information
sapphi-red committed May 22, 2022
1 parent a49bd36 commit 197253e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin {
if (config.build.minify) {
content = await minifyCSS(content, config)
}
code = `export default ${JSON.stringify(content)}`
// marking as pure to make it tree-shakable by minifier
// but the module itself is still treated as a non tree-shakable module
// because moduleSideEffects is 'no-treeshake'
code = `export default /* #__PURE__ */ (() => ${JSON.stringify(
content
)})()`
}

return {
Expand Down

0 comments on commit 197253e

Please sign in to comment.