Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Working directory issues ("_includes" instead of asset path) #14

Open
smudge opened this Issue · 11 comments

6 participants

@smudge

One of my .scss files expects to be able to @import another .scss file in the same directory, which fails when the asset pipeline runs "convert" on the content. I had to update my convert method to the following:

def convert
  Dir.chdir "../_assets/scss" do
    return Sass::Engine.new(@content, syntax: :scss).render
  end
end

It would be great if the 'convert' method were executed from within the same directory as the file being converted.

@waitingallday

Try this instead

def convert
  return Sass::Engine.new(@content, load_paths: ['.','_assets'], syntax: :scss).render
end
@smudge

That works too, yep. It still doesn't get around the problem of the converter needing to just kind of 'know' the directory structure around it, but I suppose that could be by design.

@waitingallday

Yeah that's a good point. Keeping the structure awareness out does makes it seem leaner though.

Adding _assets to the load_paths by default is probably going to cover most people, maybe it just needs an update to the documentation?

@matthodan
Owner

I'll take a closer look at this this weekend, but I agree there is a bit of a gotcha here. UPDATE 2/8/13: This is still on my radar, but have been busy with a couple of other things and haven't had a chance to dig into this yet.

@samheuck

It would be handy to have a "base path" configuration setting so that custom load paths could be relative to a consistent directory. Not sure how to do this, I'm not very well versed in ruby.

@tmaslen

I had the same problem. Got it running now by telling the convert method where to run sass. Both examples above need to be edited to point at the dir where all the scss files are kept, i.e.

    def convert
      return Sass::Engine.new(@content, load_paths: ['.','_assets/dev/css/baseline'], syntax: :scss).render
    end

This is a great jekyll plugin by the way, thanks for making it. :-)

@mattymess

I can't, for the life of me, get my SCSS to compile correctly. My assets are stored in /_assets and i'm using the following in the convert method:

return Sass::Engine.new(@content, load_paths: ['.','_assets'], syntax: :scss).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 /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
  /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
@tmaslen

Never seen the dot notation ".css.scss", does it work if the file name is just "_variables.scss"?

@mattymess

It's a convention that's used with the Rails asset pipeline. This gem supports it if you want to do successive preprocessing like ERB > SCSS > CSS would be filename.css.scss.erb

To answer your question...it doesn't work if I remove '.css'

@tmaslen

What if you made "_variables.css.scss" a completely empty file?

@mattymess

I'll have to get back to you about that. I've gotta get this site up, so in the meantime, I'm just doing it with a generator plugin instead of an asset-pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.