4

I'm using spree 2.1.5, rails 4.0.2, sass-rails 4.0.0.

The spree documentation at http://guides.spreecommerce.com/developer/asset.html indicates using the vendor/assets/stylesheets folder. However, examples I see of spree stylesheet overrides on Github and from other google search show many people using the app/assets/stylesheets folder.

Is it best to override spree styles in the folder my_store/app/assets/stylesheets? Or my_store/vendor/assets/stylesheets?

sarah777724
  • 39
  • 1
  • 2

4 Answers4

5

I put my css in the "normal" place - in app/assets/stylesheets, and nothing changed. I put my css in the vendor/assets/stylesheets folder, and they were applied.

Working with Spree very un-like working with "Rails" - though spree is running on a rails server. The process starts with, "Where are the files?" and gets more bizarre from there. This is why I am abandoning it for a custom solution. In many cases, it would take longer to learn how to modify/customize Spree, than to write a new solution (for the parts of it we actually need) from scratch.

JosephK
  • 668
  • 10
  • 18
2

Update:

Unlike stated in my original answer, Spree will not even evaluate stuff in app/assets/stylesheets and style customizations need to be made in vendor/assets/stylesheets, e.g. in

vendor/assets/stylesheets/spree/frontend/all.css

TlmaK0 is perfectly right pointing this out.


Quoting from http://guides.rubyonrails.org/asset_pipeline.html:

Pipeline assets can be placed inside an application in one of three locations: app/assets, lib/assets or vendor/assets.

  • app/assets is for assets that are owned by the application, such as custom images, JavaScript files or stylesheets.
  • lib/assets is for your own libraries' code that doesn't really fit into the scope of the application or those libraries which are shared across applications.
  • vendor/assets is for assets that are owned by outside entities, such as code for JavaScript plugins and CSS frameworks.

Short: You probably want to put your override stuff into app/assets/stylesheets.

Alexander Presber
  • 6,429
  • 2
  • 37
  • 66
0

Normally all the code for font-end and back-end for spree loads into to your rvm as other gems, you can override them by creating decorators folder into app(same as like models, controllers). Or you can put the file at the same location(but this is not right solution) and can make the change like mainapp/app/views/spree/admin/shared/_header.html.erb

For decorators example say I want to override spree's products_controller I will put it at decorators/products_controller_decorator.rb

 Spree::ProductsController.class_eval do
   #mychanges
 end
Nitin Kumar
  • 184
  • 10
0

Export all views to app/views with:

rails generate spree:frontend:copy_views

This will generate all frontend views in app/views to override it.

Edit app/views/spree/shared/_head.html.erb and add:

<%= stylesheet_link_tag 'application', media: 'screen' %>

to include app/assets/stylesheets folder.

TlmaK0
  • 3,578
  • 2
  • 31
  • 51