matthodan / jekyll-asset-pipeline

Powerful asset pipeline for Jekyll that collects, converts and compresses JavaScript and CSS assets
http://www.matthodan.com/2012/11/22/jekyll-asset-pipeline.html
MIT License
364 stars 31 forks source link

Failure with Sass @import #6

Closed migreyes closed 11 years ago

migreyes commented 11 years ago

Hey Matt,

Nice work on this. In building out a new site, I'm noticing that the Asset Pipeline fails once there's an @import at the top of any stylesheet.

(I'm pulling in a mixins and reset file, both of which are currently empty. I can of course stack all of my styles in one stylesheet, but processing multiple sheets is ideal.)

migreyes commented 11 years ago

Looks as if it defaults to searching within "_includes." Placing stylesheets I'd like to import into here allows it to work.

matthodan commented 11 years ago

I just compiled my blog, which uses @import to incude several other *.scss files that share variables without any issue. Here are the entire contents of my master stylesheet:

@import '_assets/stylesheets/global.css.scss';
@import '_assets/stylesheets/layouts/default.css.scss';
@import '_assets/stylesheets/layouts/post.css.scss';
@import '_assets/stylesheets/includes/recent_posts.css.scss';
@import '_assets/stylesheets/articles.css.scss';

Is this not what you are trying to do?

migreyes commented 11 years ago

Ah, I see. You're prepending the full path before the stylesheet. The Sass @import directive usually lets you trim it down, where this works so long as mixins.scss is in the same directory as the stylesheet from where you're calling it:

@import 'mixins';

Not a real issue, we can close this one.

matthodan commented 11 years ago

Good deal. Let me know if you have any other issues!

mbillard commented 11 years ago

Just for the record, I used a slightly cleaner version of the above for my own site. In jekyll_asset_pipeline.rb I use the following:

return Sass::Engine.new(@content, syntax: :scss, load_paths: ['../_assets']).render

Note the load_paths. This allows me to use the following when importing:

@import "css/style"; // imports _assets/css/_style.scss
mattymess commented 10 years ago

My assets are stored in /_assets and i'm using the following in the convert method:

return Sass::Engine.new(@content, syntax: :scss, load_paths: ['./_assets/']).render

with the following import statement:

@import 'variables';

the variables file has the following name _variables.css.scss within the _assets directory

Still getting the error below though...

$ jekyll serve --watch
Configuration file: /Users/mattmessinger/bigframe/repos/viewfinder/_config.yml
            Source: /Users/mattmessinger/bigframe/repos/viewfinder
       Destination: /Users/mattmessinger/bigframe/repos/viewfinder/_site
      Generating... Asset Pipeline: Processing 'css_asset_tag' manifest 'global'
Failed to convert asset 'styles.css.scss'.
Asset Pipeline: Failed to convert 'styles.css.scss' with 'JekyllAssetPipeline::SassConverter'.
  Liquid Exception: File to import not found or unreadable: variables. Load paths: /Users/mattmessinger/bigframe/repos/viewfinder/_assets /Users/mattmessinger/.rvm/gems/ruby-2.0.0-p0/gems/compass-0.12.2/frameworks/blueprint/stylesheets /Users/mattmessinger/.rvm/gems/ruby-2.0.0-p0/gems/compass-0.12.2/frameworks/compass/stylesheets Compass::SpriteImporter in _includes/header.html
error: File to import not found or unreadable: variables.
Load paths:
  /Users/mattmessinger/bigframe/repos/viewfinder/_assets
  /Users/mattmessinger/.rvm/gems/ruby-2.0.0-p0/gems/compass-0.12.2/frameworks/blueprint/stylesheets
  /Users/mattmessinger/.rvm/gems/ruby-2.0.0-p0/gems/compass-0.12.2/frameworks/compass/stylesheets
  Compass::SpriteImporter. Use --trace to view backtrace