Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import Sass files by identifier #1397

Closed
agross opened this issue Jan 14, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@agross
Copy link
Contributor

commented Jan 14, 2019

I use Sass syntax (not Scss). Since the new sourcemap-enabled importer hard-codes :scss syntax, I cannot use @import with item identifiers if the item's content syntax is Sass.

Steps to reproduce

  1. Set up documented example
  2. Make sure the partial contains Sass syntax-specific code
  3. Compile

Example repo here: https://github.com/agross/nanoc-sass-partials-by-id

Expected behavior

Compilation succeeds

Actual behavior

Compilation fails

$ nanoc
Loading site… done
Compiling site…
/app.sass:4 DEBUG: Could import by relative path

Captain! We’ve been hit!

Sass::SyntaxError: Invalid CSS after "..."$this-is-sass"": expected "{", was ""

Current item: /app.sass (:default representation)

  0. /_partial.sass:3
  1. /app.sass:6

Details

The build output should contain both /app.sass:4 DEBUG: Could import by relative path and 'Could import by item identifier'.

I need to use @import "/item/identifier.sass" instead of plain files because plain files cause a dependency on all items' raw content. This essentially disables Nanoc's caching for the Sass filter output.

Crash log

https://gist.github.com/agross/ada776af1111de4d54f5f84c81200142

@agross

This comment has been minimized.

Copy link
Contributor Author

commented Jan 14, 2019

FWIW, before the importer sets the syntax to :scss, options[:syntax] already equals :sass. I guess removing that assignment will then break Sass importing Scss . I think Nanoc needs to somehow guess the syntax.

@agross

This comment has been minimized.

Copy link
Contributor Author

commented Jan 14, 2019

Perhaps something like options[:syntax] = File.extname(identifier.to_s).delete('.').downcase.to_sym will work.

@agross

This comment has been minimized.

Copy link
Contributor Author

commented Jan 17, 2019

@gpakosz FYI

@gpakosz

This comment has been minimized.

Copy link
Member

commented Jan 17, 2019

Hi @agross, I'm currently in holidays. I'll have a look next week.

@agross

This comment has been minimized.

Copy link
Contributor Author

commented Jan 17, 2019

👍 Enjoy!

agross added a commit to agross/nanoc that referenced this issue Feb 11, 2019

@ddfreyne ddfreyne closed this in 57b8bc5 Feb 16, 2019

ddfreyne added a commit that referenced this issue Feb 16, 2019

Merge pull request #1407 from agross/import-sass-by-id
Infer Sass syntax from item identifier extension, closes #1397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.