Should support tree-shaking in production
See original GitHub issueif you import style from app.css.ts
// app.css.ts
export const styleA = style({
display: 'flex'
})
export const styleB = style({ // no used
display: 'flex'
})
// App.tsx
import { styleA } from './app.css.ts'
export const App = () => {
return <div className={styleA}/>
It’s surprising that vanilla extract doesn’t do any tree-shaking which means both styleA and styleB will all include in the CSS bundle
Maybe related to these code https://github.com/seek-oss/vanilla-extract/blob/aebf9349371d631a38145df70c7de40643843554/packages/integration/src/processVanillaFile.ts#L94-L99
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Tree Shaking - webpack
The sideEffects and usedExports (more known as tree shaking) optimizations are two different things. sideEffects is much more effective since it allows to...
Read more >Tree-Shaking: A Reference Guide - Smashing Magazine
Tree-shaking” is a must-have performance optimization when bundling JavaScript. In this article, we dive deeper on how exactly it works and ...
Read more >Should support tree-shaking in production · Issue #700 - GitHub
Tree shaking is a bundler feature, we can't implement it inside of vanilla-extract. However, vanilla-extract does generate code that can be tree ...
Read more >Tree shaking and code splitting in webpack - LogRocket Blog
Tree shaking, also known as dead code elimination, is the practice of removing unused code in your production build.
Read more >Reduce JavaScript payloads with tree shaking - web.dev
In production builds, webpack can be configured to "shake" off exports from ES6 modules that weren't explicitly imported, making those production builds ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ddhp I did not use PurgeCSS as a plugin. Instead I wrote a script and run it after build. Check my repo https://github.com/pakholeung37/loft-mix/search?q=purgecss
Hi I am trying to get tree shaking to work with PurgeCSS, but it would remove all the style.
Here is the minimal reproduce repo https://stackblitz.com/edit/vercel-next-js-cidu1b?file=README.md
Have I missed something?
next.js native css-module is working fine
Thanks!