Giter Club home page Giter Club logo

Comments (10)

chriseppstein avatar chriseppstein commented on May 14, 2024

I'm trying to imagine a use case where an absolute path doesn't result in pain, but not finding one. Please enlighten me.

from sass.

ravinggenius avatar ravinggenius commented on May 14, 2024

It is for a CMS I'm working on. Each widget can add styles to a @mixin based on the widget's name. The @imports are then dynamically built, then the @includes are scoped to a class matching the widget's name, then the whole thing is rendered to CSS. Absolute @imports have worked just fine until 3.1.0.alpha.249; were they not supposed to this whole time?

from sass.

chriseppstein avatar chriseppstein commented on May 14, 2024

In Sass 3.1, you can build a custom Importer to bring in dynamically generated code. This is vastly preferable to generating code to disk and then importing that.

from sass.

chriseppstein avatar chriseppstein commented on May 14, 2024

Whether or not this should be supported is up to @nex3, I don't see a good use for it, it results in fragile stylesheets.

from sass.

nex3 avatar nex3 commented on May 14, 2024

Absolute path imports seem to work fine for me. Can you post a backtrace, as well as which version of Ruby you're using?

This is not a blocker for 3.1.

from sass.

nex3 avatar nex3 commented on May 14, 2024

Oh, please also post the exact Sass code you're using.

from sass.

ravinggenius avatar ravinggenius commented on May 14, 2024

I am generating the following Sass dynamically, via https://github.com/ravinggenius/scratch_pad/blob/master/lib/sass_builder.rb. This gets converted to CSS, which is then stored in a publicly accessible file. Using compass-0.11.beta.7 and sass-3.1.0....

@charset 'utf-8'
$experimental-support-for-svg: true
$experimental-support-for-khtml: false
$experimental-support-for-microsoft: true
$experimental-support-for-mozilla: false
$experimental-support-for-opera: false
$experimental-support-for-webkit: false
@import '/home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/scratch_pad-themes-default-0.0.1/lib/styles/_variables.sass'
@import 'compass/css3/font-face'
@import 'compass/reset/utilities'
@import 'compass/utilities/lists'
/* zenda license: /assets/theme/default/fonts/Zenda-fontfacekit/Paul%20Lloyd%20License%20Agreement.txt
@include font-face("zenda", font-files('/assets/theme/default/fonts/Zenda-fontfacekit/zenda-webfont.woff', woff, '/assets/theme/default/fonts/Zenda-fontfacekit/zenda-webfont.ttf', truetype, '/assets/theme/default/fonts/Zenda-fontfacekit/zenda-webfont.svg', svg), '/assets/theme/default/fonts/Zenda-fontfacekit/zenda-webfont.eot')
@import '/home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/scratch_pad-widgets-system_menu-0.0.2/lib/styles/all.sass'
@import '/home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/scratch_pad-themes-default-0.0.1/lib/styles/all.sass'
@media all
  @include global-reset
  @include reset-html5
  .system-menu
    @include system_menu_all
  @include default_all

Stacktrace:

Sass::SyntaxError (File to import not found or unreadable: /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/scratch_pad-themes-default-0.0.1/lib/styles/_variables.sass.
Load paths:
  /home/thomas/Code/ravinggenius-scratch_pad/app/stylesheets
  /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/compass-0.11.beta.7/frameworks/blueprint/stylesheets
  /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/compass-0.11.beta.7/frameworks/compass/stylesheets
  /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/compass-susy-plugin-0.8.1/sass
  ):
  lib/sass_builder.rb:27:in `to_css'
  app/controllers/assets_controller.rb:40:in `styles'

Rendered /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
Rendered /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.9ms)
Rendered /home/thomas/.rvm/gems/ruby-1.9.2-p0@development/gems/actionpack-3.0.7/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (8.8ms)

Thanks for trying to understand this and help me. I really appreciate the work you guys are doing.

from sass.

ravinggenius avatar ravinggenius commented on May 14, 2024

@chriseppstein helped me work around this issue by converting the absolute paths to relative paths. Still not sure why the absolute paths wouldn't work.

from sass.

stefankroes avatar stefankroes commented on May 14, 2024

what was the work around? I have a similar issue.

Using absolute paths the first file is imported correctly but instead of importing the second file it seems to import the first file again. (Strange, i know)

At first I suspected a caching issue but even with different filename the behavior remains.

from sass.

ravinggenius avatar ravinggenius commented on May 14, 2024

@stefankroes I am converting all @import paths from absolute to relative with a bit of Ruby:

def prepare_path_for_import(path)
  reply = Pathname.new path
  # if the path is absolute, return a relative path
  reply.absolute? ? reply.relative_path_from(Pathname.new(Compass.configuration.sass_path)) : reply
end

I am generating this main Sass file in Ruby, so it was pretty easy to add this code to my project. I hope it helps.

from sass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.