lucasmazza / spriteful

You know, sprites
Other
154 stars 13 forks source link

Better Rails defaults #28

Open lucasmazza opened 9 years ago

lucasmazza commented 9 years ago

I haven't used Spriteful in a while, but I would like to improve some of the default conventions for Rails apps to assess some issues I had in the past and take some advantage of the recent improvements of Sprockets 3

Use app/assets/sprites instead.

Currently, we use the app/assets/images/sprites and app/assets/stylesheets/sprites directories of a Rails app for sprites auto discovery and output destination. Since most apps precompile everything inside the images directory by default, we end up with the source images precompiled along the combined image and stylesheet.

We could move everything to app/assets/sprites, which would outline the sprite assets apart from the rest of the images and stylesheets, and would skip the compilation of source images. Instead of having the following pattern:

We would have the following:

We could support both structures before hitting 1.0.0, and emit warnings whenever necessary.

Use Manifest links

The generated stylesheets could support the link directive from Sprockets 3 to ensure that everything gets precompiled when necessary, and provide a manifest that links all the sprites in the application (not sure yet if this should be mandatory).

// app/assets/sprites/_icons.scss
//= link ./icons.png
// app/assets/sprites/all.css OR app/assets/sprites.css
//= link_tree ./text/css (or link_tree ./sprites)

Applications could simply ask to precompile the general manifest or require/import each generated stylesheet as necessary.

/cc @rafaelfranca

rafaelfranca commented 9 years ago

Both ideas are great, but I was wondering, why not app/assets/sprites instead of app/sprites?

lucasmazza commented 9 years ago

@rafaelfranca yeah it should. Updated the original description.

rafaelfranca commented 9 years ago

Lets do this.