rails / sprockets-rails

Sprockets Rails integration
MIT License
574 stars 244 forks source link

require_tree doesn't pull all files in when precompiling #272

Open Martin288 opened 9 years ago

Martin288 commented 9 years ago

Hi guys, recently I meet a weird problem but I can not find any solution. The below shows my assets organization:

--- app
 |--- assets
   |--- stylesheets
     |--- home.css
     |--- home
       |--- file1.css.scss
       |--- file2.css.scss
       |--- file3.css.scss

The below lists the content in my app/assets/stylesheets/home.css:

/*
 * require bootstrap
 * require pickaday
 * require_tree ./home

As the file shown, I need to require two stylesheets under vender directory and require all files under app/assets/stylesheets/home, but when I run RAILS_ENV=staging rake assets:precompile, the precompiled file public/assets/home-xxxxxxxxxxxxxxxx.css only includes codes from bootstrap, pickaday, file2 and file3, which excludes file1. I have tried to delete the precompiled assets and re-run the command, but the same result appeared again.

Is there anything should pay attention to when work with require_tree directive?

rafaelfranca commented 9 years ago

Is there any chance of file1 be called index?

On Sun, Sep 6, 2015, 04:56 Martin288 notifications@github.com wrote:

Hi guys, recently I meet a weird problem but I can not find any solution. The below shows my assets organization:

--- app |--- assets |--- stylesheets |--- home.css |--- home |--- file1.css.scss |--- file2.css.scss |--- file3.css.scss

The below lists the content in my app/assets/stylesheets/home.css:

/* * require bootstrap * require pickaday * require_tree ./home

As the file shown, I need to require two stylesheets under vender directory and require all files under app/assets/stylesheets/home, but when I run RAILS_ENV=staging rake assets:precompile, the precompiled file public/assets/home-xxxxxxxxxxxxxxxx.css only includes codes from bootstrap, pickaday, file2 and file3, which excludes file1. I have tried to delete the precompiled assets and re-run the command, but the same result appeared again.

Is there anything should pay attention to when work with require_tree directive?

— Reply to this email directly or view it on GitHub https://github.com/rails/sprockets-rails/issues/272.

Martin288 commented 9 years ago

@rafaelfranca no, it is named begin_promotion.css.scss.

Martin288 commented 9 years ago

@rafaelfranca additional information here:

If I continue to add new file under app/assets/stylesheets/home/, it seems that it can not detect any changes with new added file, I need to modify an existed file such as file2.css.scss to make assets pipeline to precompile the home.css so that new added file will get a chance to be pulled in. But unfortunately, this behaviour appears randomly.

Martin288 commented 9 years ago

Update again:

Today I tried to deploy the application from another git branch, which doesn't require begin_promotion.css.scss and hence there is no this file in the repo, but when capistrano run rake assets:precompile, it complained that:

Sprockets::FileNotFound: could not find file: /xxxxxxx/releases/20150908075154/app/assets/stylesheets/home/begin_promotion.css.scss

It seems like that Sprockets always try to load files from something cached?

rafaelfranca commented 9 years ago

Looks like you are having caching problems. Can you please provide a sample application that reproduces the error?