Help us understand the problem. What is going on with this article?

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

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

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";

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした