0
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?

Github actionでcssが適応されない

Last updated at Posted at 2025-04-12

自動的に生成されるCSSのファイル名がおかしい問題

vite + Reactでtodoアプリを作成したさいに発生した問題です。
ローカルでは問題なくCSSが適応されているが、ghactionでは適応されていないのが問題でした。

問題の部分

dist/assets/.cssB7eOPUfC
上記のように謎のファイル形式名になっている。
VScodeでは、CSSと認識されている。
しかし、ghactionでは認識できず適応されていない。

解決策

[hash].cssにする。

vite.config.ts
cssCodeSplit: true,
assetFileNames: "assets/[hash].css",

原因

デフォルトの状態は以下です。

vite.config.ts
assetFileNames: 
"assets/[name]-[hash][extname]",

[name]が.cssにあたり、
[hash]がB7eOPUfCにあたります。

0
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
0
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?