Skip to content

Commit b491ccf

Browse files
author
Jesse Goodnoe
committed
Make it more obvious in README to not use Sprocket's require directives.
fixes zweilove#15
1 parent 4a6a060 commit b491ccf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,24 @@ If you have more questions about how it works, look at the code or contact us.
7979

8080
If you want to split a style (e.g. `assets/stylesheets/application.*`) and have a JS asset with the same name (`assets/javascripts/application.*`) in your asset load_path (as is the default in Rails), you need to include the stylesheet along with the file extension `// = include 'application.css'` because otherwise it will try to include the JS asset of the same name instead. Sprocket's `= include` directive doesn't seem to differentiate between different types/folders and just takes the first asset it can find for any given name (see #10).
8181

82-
#### Don't use Sprocket's `= require_tree .` for stylesheets
82+
#### Don't use Sprocket's `= require_tree .` or `= require_self` for stylesheets
83+
It's recommended that you **always use Sass's `@import`** for all your stylesheets in favor of Sprocket's `= require` directives, just as the official `sass-rails` gem says: https://github.com/rails/sass-rails#important-note
8384

84-
If you require a `.split2` stylesheet in your tree that in turns includes the base stylesheet like shown below, you will end up with a nasty `Sprockets::CircularDependencyError`!
85+
If you have a `.split2` stylesheet in your tree that in turn includes the base stylesheet like shown below, you will end up with a nasty `Sprockets::CircularDependencyError`!
8586

8687
/* assets/stylesheets/application.css */
8788
/* = require_tree .
8889

8990
/* assets/stylesheets/application_split2.css.split2 */
9091
/* = include 'application.css' */
9192

92-
To avoid this it's recommended to **always use Sass's `@import`** for all your stylesheets in favor of Sprocket's `= require` directives, just as the official `sass-rails` gem says: https://github.com/rails/sass-rails#important-note
93+
If you have `require_self` in the stylesheet that you're splitting, as shown below, the `.split2` will end up having **both** the original stylesheet and the split contents. You'll end up with an even bigger stylesheet.
94+
95+
/* assets/stylesheets/application.css */
96+
/* = require_self
97+
98+
/* assets/stylesheets/application_split2.css.split2 */
99+
/* = include 'application.css' */
93100

94101

95102
## Limitations & Known Issues

0 commit comments

Comments
 (0)