Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不必要な CSS の削除 #9

Open
shun91 opened this issue Dec 8, 2021 · 4 comments
Open

不必要な CSS の削除 #9

shun91 opened this issue Dec 8, 2021 · 4 comments

Comments

@shun91
Copy link
Owner Author

shun91 commented Dec 8, 2021

複数ページ遷移しつつcoverageを確認したら、ほとんど不必要なCSSだ...
ただ、どうしたら削減できるかは現段階で不明。

image

@shun91
Copy link
Owner Author

shun91 commented Dec 8, 2021

yarn build時に以下の警告が出ている。

warn - Tailwind is not purging unused styles because no template paths have been provided.
warn - If you have manually configured PurgeCSS outside of Tailwind or are deliberately not removing unused styles, set `purge: false` in your Tailwind config file to silence this warning.
warn - https://tailwindcss.com/docs/controlling-file-size/#removing-unused-css

↓翻訳

テンプレートパスが提供されていないため、Tailwindは未使用のスタイルを削除していません。
Tailwindの外部でPurgeCSSを手動で構成した場合、または未使用のスタイルを意図的に削除しない場合は、Tailwind構成ファイルで `purge:false`を設定して、この警告を消します。
https://tailwindcss.com/docs/controlling-file-size/#removing-unused-css

提示されたURLに記載されている通り、purgeを設定してみる。

diff --git a/client/tailwind.config.js b/client/tailwind.config.js
index a4f9cbb..e99f9bf 100644
--- a/client/tailwind.config.js
+++ b/client/tailwind.config.js
@@ -1,3 +1,4 @@
 module.exports = {
   darkMode: false,
+  purge: ['./src/**/*.html', './src/**/*.jsx'],
 };

もともと3MiBぐらいあったcssがめっちゃ軽くなった。

asset styles/main.css 381 KiB [emitted] [big] (name: main)

@shun91
Copy link
Owner Author

shun91 commented Dec 8, 2021

image

@shun91
Copy link
Owner Author

shun91 commented Dec 8, 2021

まだまだ不必要なCSSは多そうだが、ひとまず後回しにする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant