1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ViteでReact x TypeScriptで立ち上げたプロジェクトからcss関連の記述を消す

1
Last updated at Posted at 2026-09-19

はじめに

  • 何度も検証用、練習用にviteプロジェクトを立ち上げている

問題

  • 不要な記述は触りたいファイルないから消すなら手動でいいけど、cssはあっちこっちいくから面倒

解決

  • 以下のコマンドで解決
rm src/App.css
rm src/index.css
grep -v 'import.*\.css' src/App.tsx > src/App.tsx.tmp && mv src/App.tsx.tmp src/App.tsx
grep -v 'import.*\.css' src/main.tsx > src/main.tsx.tmp && mv src/main.tsx.tmp src/main.tsx

終わりに

  • 以下の組み合わせでtmpファイルを作って対応するのは結構頻繁に使えそう。個々を深掘りしていきたい
    • grep -v マッチしなかった行
    • > リダイレクトで全部書き込む
    • 正規表現
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?