新しい歴史

スタイリッシュなコンポーネントから Tailwind CSS: A HackerNoon Migration Story

beni mahat4m2025/04/15
Read on Terminal Reader

長すぎる; 読むには

HackerNoonはスタイリングコンポーネントからタイルウィンドCSSに移行し、フロントエンドを近代化し、混乱を減らし、パフォーマンスを向上させています。タイルウィンドは今、ホームページでライブで、AIが一度に1つのコンポーネントを再構築するのを助けています。この動きは再びビルディングを楽しくさせました。これは私たちが軽く決断したのではありません。スタイリングコンポーネントは長い間私たちによく役立ちました。しかし、私たちがスケールするにつれて、コミットオフはより明確になり始めました - 特にパフォーマンス、一貫性、長期的なメンテナビリティに関して。この投稿は、私たちが当初スタイリングコンポーネントを選
featured image - スタイリッシュなコンポーネントから Tailwind CSS: A HackerNoon Migration Story
beni mahat HackerNoon profile picture
0-item
1-item


毎回、かつて正しく感じたテクノロジースタックの決定は、スクリュードライバーがパワードリルを使用した後にどれほど効率が低いかを認識するように、その限界を示し始めます。 HackerNoon が Styled Components を使用したことでそうでした。何年もの間、それは私たちにうまく役立ち、スケールされたスタイル、ダイナミックなテーマ化、そして React コンポーネント内の完全なコントロールを提供しました。しかし、私たちのコードベースが進化し、 Tailwind CSS のようなツールが成熟したにつれて、 変更が遅れてしまいました。スタイリングコンポーネントタイルウィンド CSS変更が遅れました。


This post is a breakdown of our shift from Styled Components to Tailwind CSS, why we made the move, how I approached the transition, and what the process has looked like so far. If you are working with legacy styles or considering Tailwind for your own projects, hopefully this gives you something useful (or at least relatable) to walk away with.

Why HackerNoon Originally Used Styled Components

Styled Components が最初に CSS を扱うために選択されたとき、私はチームの一員ではなかったが、当時、Tailwind CSS はまだリリースされていなかったし、Styled Components は HackerNoon のフロントエンドアーキテクチャに多くの意味を持ちました。Tailwind CSS はまだリリースされていません


これは、開発者がJavaScript内で直接CSSを書くことを可能にし、コンポーネントを完全に自己コンテンツにします。このアプローチは、自然に非常に「React-native」と感じた――encapsulated、reusable、そして、当時、成長するコードベースとチームでより維持しやすくなると考えられました。ダイナミックなスタイリング機能、内蔵のテーマサポート、およびスタイルにプロプションを直接転送する能力は、私たちが構築していた幅広いページやレイアウトのために特によく機能しました。encapsulated, reusable, and, at the time, thought to be easier to maintain encapsulated, reusable, and, at the time, thought to be easier to maintainStyled Components served HackerNoon well

What Made Us Consider Switching to Tailwind?

時間の経過とともに、コードベースは増加し、管理スタイルの複雑さも増加した。


Styled Components は私たちに柔軟性を提供しましたが、これはコストがかかりました: より大きなバンドサイズ ランタイムパフォーマンスヒット、および より長いスタイリングブロックで満たされた コンポーネント構造より大きなバンドサイズruntime performance hitscluttered コンポーネント構造


We also noticed many of our styles were repeating across components. That's when Tailwind CSS began to make a lot of sense. ユーティリティーファーストアプローチは、レイアウトから反応性まで、すべてを簡素化する方法のように感じた。タイルウィンド CSS


But let's be real: for a small developer team like HackerNoon's, the idea of refactoring a massive codebase line by line felt like a huge undertaking. Yet, we couldn't ignore how widely Tailwind was being adopted in the developer community. We wanted in.

small dev team like HackerNoon'sline by line

How I Made the Switch

このスイッチの最も難しい部分は? Setup.

トップページ


Tailwindのインストールは簡単でしたが、アクティブになったら、PreflightのおかげでTailwindのグローバルなスタイルは既存のコンポーネントと衝突し始めました。


A lifesaver here was setting preflight: false in the tailwind.config.js file. That move disabled most of Tailwind's base resets, which brought back some order. もちろん、まだ小さなスタイリングの問題が修正されていたが、物事は戦争ゾーンのように見えなかった。preflight: falsetailwind.config.jsタイルウィンドのベースリセットのほとんどを無効にした


そこから、私たちはグローバルなスタイルをどのように取り扱い、クラスを再利用し、Tailwindでテーマを意識するコンポーネントを構築するかという新しい条約を強く確立しなければなりませんでした。establish new conventions 新しい条約を確立する


And here's the part I'm still amazed by: AI made this process actually enjoyable.

AIはこのプロセスを実際に楽しいものにしました。


数千行のコードソロを再現することは狂気だったが、チャットGPTを使用してスタイリングされたコンポーネントをタイムウィンドに1つずつ変換した。


Now, let me be honest: AI didn't get everything right. More complex, themed components still required manual coding and plenty of hours. But having a solid base to start from made things so much easier. Tailwind's documentation also helped fill the gaps, and once I fully embraced the utility class mindset, things started to click.

Now, let me be honest:手動コーディングと多くの時間utility class mindset

What the Migration Looks Like So Far

I'm happy to say Tailwind is now live on HackerNoon! 🎉

Tailwind is now live on HackerNoon!


As of now, the HackerNoon Homepage is fully converted to Tailwind CSS, with Styled Components completely removed. Most of the other pages still rely on Styled Components, and they’ll be converted gradually—one component, one page at a time.

HackerNoon Homepage is fully convertedHackerNoon Homepage is fully convertedone component, one page at a time 1ページ


この遅いアプローチは実際には祝福でした。各コンポーネントを再構成することで、ページのデザインと構造を 見直し、 を改善することができました。Tailwind 変換に加えて、私たちは より近代的な UI、より良いレイアウトの使用、新しいコンポーネント、そして私たちの古いテーマシステムを恥じさせる トピックピッカーを追加しました。revisit and improve more modern UI Custom-built theme picker


HackerNoonで4年以上働いた後、私はreignitedが再び私たちのコードベースに潜入していると感じています。 Tailwindは再びビルディングを楽しませてきました。それはクリーンで、一貫性があり、強力です - そして私は変換を前進させ続けることに興奮しています。誰が知っているでしょうか? もしかしたら、近いうちに私たちはpackage.jsonからstyled-componentsを削除します。reignited トップページstyled-componentspackage.json


Final Tailwinding Thoughts

Tailwind CSSへの移行はスタイリングライブラリの交換だけではなく、フロントエンドのワークフローを近代化し、一貫性を採用し、開発を簡素化することでした。柔軟性、スピード、および維持性


それはまだ進行中の仕事です - 私たちのアプリにはまだ多くのスタイリングコンポーネントがあります - しかし、私たちのホームページと新しく改装されたコンポーネントでTailwindをライブで見ることは信じられないほど有益です。


HackerNoonは進化しており、私たちのスタイルはそれとともに進化しています。

Trending Topics

blockchaincryptocurrencyhackernoon-top-storyprogrammingsoftware-developmenttechnologystartuphackernoon-booksBitcoinbooks