ローカル環境では問題なく動いていたのにherokuでデプロイ中にprecompiling assets failedとエラーが出たので解決方法をまとめます。
logを調べているうちに環境内に問題がありそうだったので
ターミナルでエラー解析をします。
RAILS_ENV=development bin/rails assets:precompile
こちらを実行することで開発環境ないでエラーがないかを確認することができます。
中身を見てみると、、、
warning Integrity check: Flags don't match
error Integrity check failed
error Found 1 errors.
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).
ローカルでyarnを最新の状態にしているからなのかファイルのバージョンに古いのがあったためupdateする必要があったのかなと思います。
また、
To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).
このままではチェックと指示があるので下記のように変更します。
/config/webpacker.yml
check_yarn_integrity: false
この状態でもエラーが出たので下記コマンドで本番環境で問題がないか確認してみます。
RAILS_ENV=production bin/rails assets:precompile
UnitConversionError Incompatible units: 'px' and ‘%’
imcompatibleは相容れないという意味なんおでpxと%を同時に使っている可能性があります。
.main{
height: (100% - 780px);
margin: 0 auto;
}
heightの計算にcalcを書いてない!!
.main{
height: calc(100% - 780px);
margin: 0 auto;
}
もう一度デプロイするとうまくいきました。