Domanda

I am trying to build a Rails Engine which serves assets to its host application. Specifically, I would like to be able to do the following:

# Host App's Gemfile
gem 'my-rockin-engine'

And ...

# Host App's application.css
/*
 *= require styles
 */

@import 'my-rockin-engine/mixins'

And ...

# Host App's style.sass
.host-app-defined-class-name
  +my-rockin-engines-mixin

Where the mixin "my-rockin-engines-mixin" is defined somewhere in the assets of MyRockinEngine.

The problem

I have a chain of @imports from the host app, through the engine. (I'm using @imports due to reasons described here.) Any style definitions that I create inside the Engine's assets are available to the host app. However, none of the SASS mixins I create are available anywhere other than in the same file that the mixin is defined in.

Essentially, I'm wondering if my implementation is not working because either (1) I'm using Engines in a confused way; (2) It is not possible to share mixins between Rails Engines and their host application; (3) There is some aspect of sprockets/rails/compass/sass (@import/require) directives that I am misunderstanding.

Any help would be greatly appreciated! And I can always offer further details should anyone need them.

È stato utile?

Soluzione

For posterity, it seems the problem I was having was in the realm of (3) -- described in my question.

Don't try and @import sass files which are named foobar.css.sass. Compass will treat such files as css, since they have to be imported via @import 'foobar.css'. @import foobar will fail because the .css is part of the filename.

So, my problem is solved by ensuring any files I @import use the .sass extension, and don't have .css in the last part of the file name.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top