前提・実現したいこと
簡単なRailsアプリをherokuにデプロイする。
=>デプロイはできるがbootstrapやcssが効かない。
↓app/assets/javascript/application.js↓
js
1//= require rails-ujs 2//= require jquery 3//= require bootstrap-sprockets 4//= require activestorage 5//= require turbolinks 6//= require_tree . 7
↓app/assets/stylesheet/application.scss↓
scss
1@import "bootstrap-sprockets"; 2@import "bootstrap"; 3 4.hogehoge { 5 something... 6}
発生している問題・エラーメッセージ
開発環境では正しく表示できるが、heroku上でスタイルがうまく当たらない
該当のソースコード
↓herokuデプロイ時のログ↓
Counting objects: 5, done. Delta compression using up to 8 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 498 bytes | 498.00 KiB/s, done. Total 5 (delta 3), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.4.0 remote: -----> Installing dependencies using bundler 1.15.2 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.17.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. remote: Fetching gem metadata from https://rubygems.org/...... ...... remote: Bundle completed (3.53s) ... remote: -----> Installing node-v10.14.1-linux-x64 remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: Yarn executable was not detected in the system. remote: Download Yarn at https://yarnpkg.com/en/docs/install remote: Asset precompilation completed (1.83s) remote: Cleaning assets remote: Running: rake assets:clean remote: -----> Detecting rails configuration remote: remote: ###### WARNING: remote: remote: You set your `config.active_storage.service` to :local in production. remote: If you are uploading files to this app, they will not persist after the ... remote: remote: remote: ###### WARNING: remote: remote: We detected that some binary dependencies required to ... remote: remote: remote: ###### WARNING: remote: remote: No Procfile detected, using the default web server. ... remote: remote: remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: Default types for buildpack -> console, rake, web remote: remote: -----> Compressing... remote: Done: 61.7M remote: -----> Launching... remote: Released v19 remote: https://myapp/ deployed to Heroku remote: remote: Verifying deploy... done.
試したこと
app/config/initializer/assets.rbに以下を追記
Rails.application.config.assets.precompile += %w( *.js *application.css )
補足情報(FW/ツールのバージョンなど)
Rails-v => 5.2.2
Ruby-v => 2.4.0
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。