We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In Rails we use helpers to refer to assets in CSS:
background-image: image-url("icon-pointer.png"); background-image: asset-url("icon-pointer.png");
This makes the asset pipeline in Rails work: instead of linking to icon-pointer.png, it will link to the fingerprinted version of the file.
icon-pointer.png
Currently GOV.UK Frontend just uses url("file.png") in the CSS, so Rails won't point the correct assets:
govuk-frontend/package/tools/_file-url.scss
Line 4 in 5bb66d6
For GOV.UK to use GOV.UK Frontend, we'll need a way to override the govuk-file-url or to instruct it to use asset-url.
govuk-file-url
asset-url
I thought maybe defining the govuk-file-url function above the @import for GOV.UK Frontend would work, but the later definition overrides this.
@import
This doesn't work because govuk-file-url is already used by the CSS.
I though maybe if we wrap the function in a conditional like below, our override might work.
@if function-exists('govuk-file-url') == false { @function govuk-file-url($file) { @return url($govuk-global-images + $file); } }
Unfortunately SCSS errors out with:
Functions may not be defined within control directives or other mixins.
This works:
$govuk-use-rails: true; @function govuk-file-url($file) { @if $govuk-use-rails { @return asset-url($file); } else { @return url($govuk-global-images + $file); } }
This follows a spike into using GOV.UK Frontend on GOV.UK (alphagov/govuk_publishing_components#328).
The text was updated successfully, but these errors were encountered:
Hey @tijmenb,
Thanks for raising – can you take a look at #733 and see if it'll address your needs?
Ta
Sorry, something went wrong.
@36degrees tested by hacking it into the PR: alphagov/govuk_publishing_components@643c482. Works well! 👌
Thanks for the great issue @tijmenb 👍
Successfully merging a pull request may close this issue.
In Rails we use helpers to refer to assets in CSS:
This makes the asset pipeline in Rails work: instead of linking to
icon-pointer.png
, it will link to the fingerprinted version of the file.Currently GOV.UK Frontend just uses url("file.png") in the CSS, so Rails won't point the correct assets:
govuk-frontend/package/tools/_file-url.scss
Line 4 in 5bb66d6
For GOV.UK to use GOV.UK Frontend, we'll need a way to override the
govuk-file-url
or to instruct it to useasset-url
.Options
Defining the function firstI thought maybe defining the
govuk-file-url
function above the@import
for GOV.UK Frontend would work, but the later definition overrides this.Defining the function lastThis doesn't work because
govuk-file-url
is already used by the CSS.Conditionally defining the functionI though maybe if we wrap the function in a conditional like below, our override might work.
Unfortunately SCSS errors out with:
Conditional inside function
This works:
This follows a spike into using GOV.UK Frontend on GOV.UK (alphagov/govuk_publishing_components#328).
The text was updated successfully, but these errors were encountered: