3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Active adminのCSSの影響を取り除く

Posted at

Active AdminのCSSの影響を取り除く

現在RailsでWebアプリを作成しています。
Bootstrapの表示が正常にできないと思ったら、ActiveAdminのCSSと競合しているということがわかりました。そのときの解決の備忘録を書いておきます。

前提

  • react-bootstrapにてフロントでbootstrapとreactを利用
  • devise, active adminは既に導入済み
  • rails 6.x
  • ruby 2.7.2

で動かしています。

作業

  1. config/initializers/active_admin.rbに追記する。
config/initializers/active_admin.rb
  config.clear_stylesheets!
  config.register_stylesheet 'active_admin'

  config.clear_javascripts!
  config.register_javascript 'active_admin'

2.app/assets/stylesheets/application.cssから、 *= require_tree . を取り除く

app/assets/stylesheets/application.css
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *= require bootstrap/dist/css/bootstrap.min.css
 *= require_self
 */

ハマった所

The asset "active_admin.scss.css" is not present in the asset pipeline のエラーが発生した。
config/initializers/active_admin.rbの設定に拡張子(.scss)を追加して書いていたため、.scss.cssを参照してしまっていた。

*=require tree .を外すことでbootstrapとactive_adminのcssの競合を排除できることに気が付かなかった。

以上です。

3
3
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?