generated with Platane/snk
cra-clsx-purge's Introduction
cra-clsx-purge's People
cra-clsx-purge's Issues
成果物のcssから参照していないクラスのスタイル定義を除きたい
前提
- create-react-app
- CSS modules
- clsx lukeed/clsx: A tiny (228B) utility for constructing
className
strings conditionally.
背景
リリース日が決まっている機能をコメントアウトしておきたい。
例えば、以下のコードなら main.3586cee0.css から.App_DangerousKeyword__iNAki
を隠したい。
手段
ビルド前
使われていないCSSルールを検出する stylelint-no-unused-selectors を作った - 徒然技術日記
パーサがclassnamesに対応しているが、clsxには未対応。
上記の例だと、該当箇所にclsxは使われていないが、1箇所でもclsxが使われているとパーサはclsxを解釈出来ないので、そのclassNameに使用しているクラス達を未使用と検知してしまう。
clsx対応したp-rを送りつけるとなんとかなりそう。
ビルド後
PurgeCSS
When using CSS modules, the names of your classes are replaced by a hash. For this reason, working with CSS modules and PurgeCSS might not be as straightforward as you would want it to be.
css modules はクラス名に自動でsuffixを付けるのでnpm run eject
するしかないが、出来れば避けたい。
react-app-rewired
でなんとかなるかもしれない
rollup-plugin-purgecss
create-react-app
をやめて、viteからrollup-plugin-purgecss - npmを使う方法もある
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.