LoginSignup
4
3

More than 3 years have passed since last update.

gatsbyビルド時に起きるmaterial-uiのスタイル崩れを直す

Last updated at Posted at 2020-01-12

gatsbyビルド時にmaterial-uiのスタイルが崩れてしまった

gatsbyで開発したwebアプリをリリースしたらmaterial-uiで構成したコンポーネントのスタイルが崩れていました。どうやらプラグインを入れないとmaterial-uiのスタイルが崩れてしまうようです。
修正法がわかったので、共有しようと思います。

スタイル崩れの修正法

1、gatsby-plugin-material-uiをインストール

npm install gatsby-plugin-material-ui @material-ui/styles

もしくは

package.jsonに以下のようにgatsby-plugin-material-uiを加える
その後、npm installを実行
image.png

2、gatsby-config.jsにgatsby-plugin-material-uiプラグインの情報を入力する必要がある

gatsby-config.jsに以下のようにgatsby-plugin-material-uiを加える
image.png

これで、再ビルドするとmaterial-uiのcssなどのスタイルが整った。

gatsby developで立ち上がる開発環境でスタイルが崩れてない人もgatsby serveでビルド時の(本番)環境が立ち上がるのでリリース前には試しておいたほうがいいと思います。

参考にしたサイト

4
3
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
4
3