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

Raise on accidental intermediate file format use #327

Closed
schneems opened this issue Jun 25, 2016 · 3 comments
Closed

Raise on accidental intermediate file format use #327

schneems opened this issue Jun 25, 2016 · 3 comments

Comments

@schneems
Copy link
Member

This is going to be a tough one. Right now if you accidentally

env["application.scss"]

Then sprockets will render you the contents of the scss file, however you probably wanted the compiled CSS results that would come from env["application.css"].

I'm proposing we either register file formats as "internal" so that if you tried to render .scss you get an error. Alternatively we could register end user formats like .css and raise an exception if you use any format other than that. The problem with the second approach I see is that there's a ton of file formats and we would have to keep track of most of them by default. It seems easier to special case these internal formats.

The reason I think this will be hard is that sprockets works like a reactor reactor for example if you do an env["application.css"] It will internally use the same API to eventually call env[application.scss"] to get its contents until it has all the info it needs to actually build the application.css file.

Either way this is an unexpected way for your code to fail silently, instead we should fail loudly.

Related sass/sassc-rails#65 (comment)

@schneems
Copy link
Member Author

Should also raise when no extension is given.

@schneems
Copy link
Member Author

schneems commented Sep 6, 2016

So...i'm not sure what's going on here. I tried to repro this failure and i'm not able to.

I have a file foo.scss then in console

> helper.asset_path "foo.scss"
=> "/assets/foo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css"

Weird.

@schneems
Copy link
Member Author

I think this is handled somewhat by the precompile check in sprockets-rails

Sprockets::Rails::Helper::AssetNotPrecompiled: Asset `application.scss` was not declared to be precompiled in production.
Declare links to your assets in `app/assets/config/manifest.js`.

  //= link application.scss
and restart your server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant