Coder Social home page Coder Social logo

cra-clsx-purge's Introduction

cra-clsx-purge's People

Contributors

ergofriend avatar

Watchers

 avatar  avatar

cra-clsx-purge's Issues

成果物のcssから参照していないクラスのスタイル定義を除きたい

前提

背景

リリース日が決まっている機能をコメントアウトしておきたい。
例えば、以下のコードなら main.3586cee0.css から.App_DangerousKeyword__iNAkiを隠したい。

https://github.com/ErgoFriend/cra-clsx-purge/blob/a02eface0cdc77f3c2a0ecbd59737e203f5f13db/src/App.tsx#L18-L20

手段

ビルド前

使われていないCSSルールを検出する stylelint-no-unused-selectors を作った - 徒然技術日記
パーサがclassnamesに対応しているが、clsxには未対応。
上記の例だと、該当箇所にclsxは使われていないが、1箇所でもclsxが使われているとパーサはclsxを解釈出来ないので、そのclassNameに使用しているクラス達を未使用と検知してしまう。
clsx対応したp-rを送りつけるとなんとかなりそう。

ビルド後

PurgeCSS

CSS modules | 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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.