LoginSignup
35
35

More than 3 years have passed since last update.

application.scssにrequireなんちゃらを記述する際にエラーが出てしまった場合の解決方法

Last updated at Posted at 2017-05-23

想定される状況と解決方法

Ruby on Railsを用いて開発している際に、よくapplication.cssからapplication.scssに置き換えてscssファイルをインポートする形にすることもしばしあるかと思います。

例えば外部のプラグインを入れるとなった際に、application.scssに*= require ・・・を書き足してくださいと書かれているのですがこの記述をapplication.scssに書き加える場合には少し違った記述方法になるので注意が必要です。

・エラーになってしまう例

application.scss

@import "./reset";
@import "./common";
@import "./style";

*= require fullcalendar

・正しい書き方

application.scss
/*
 * 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, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, 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 styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require_self
 *= require fullcalendar
 */

@import "./reset";
@import "./common";
@import "./style";

こんな感じで書けば無事正常に動きます。

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