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

RailsのAsset Pipelineで、precompileするファイルを増やす

More than 5 years have passed since last update.

Railsはデフォルトでは、application.cssapplication.jsをコンパイルします。
が、例えばIEの場合、CSSが肥大化し過ぎて読み込みきれなかったりすることがあるようです。
確か4096とかだとか何だとか。

で、CSSを分割して回避しよう、というところにぶつかるわけです。
そんなとき、どうやってコンパイルするファイルを増やすのか。
ぶっちゃけめっちゃ簡単で、↓みたいにするだけです。

config/application.rb
Hoge::Application.configure do
  config.assets.precompile += %w(hoge.css)
end

こうすると、hoge.cssもコンパイル対象になるので、application.cssと同じように書いてあげれば、新しいファイルが生成されます。

これを応用すれば別のEngine用のCSSなんかも、本体と切り離して生成できたりします。ちょうべんり。

Why do not you register as a user and use Qiita more conveniently?
  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
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