alphagov / govuk_elements_rails

❗️GOV.UK Elements is deprecated, and will only receive major bug fixes and security patches. A gem wrapper around http://github.com/alphagov/govuk_elements that pulls stylesheet and javascript files into a Rails app.
MIT License
5 stars 4 forks source link

frontend-toolkit - gem dependency/packaging issue #33

Closed lostie closed 5 years ago

lostie commented 6 years ago

The following file that is included in the bundled gem call the following:

https://github.com/alphagov/govuk_elements_rails/blob/a15b523f39c226e40ffea9e7198ba9bed2d0431c/vendor/assets/stylesheets/_govuk-elements.scss#L1

but when the bundled file _govuk-elements.scss executes the following:

// bundled _govuk-elements.scss
// Import GOV.UK front end toolkit dependencies
@import "frontend-toolkit";

It can't successfully load it, as neither this gem includes it, neither the govuk_frontend_toolkit_gem.

For context, I've noticed this while setting the following in my main scss file for my Rails app:

// application.css.scss
@import "govuk-elements";

The actual error I got was the following:

Sass::SyntaxError - File to import not found or unreadable: frontend-toolkit.
Load paths:
<rails_app_root>/app/assets/images
<rails_app_root>/app/assets/javascripts
<rails_app_root>/app/assets/stylesheets
<rails_app_root>/lib/assets/data
<rails_app_root>/vendor/assets/images
<rails_app_root>/vendor/assets/javascripts
<rails_app_root>/vendor/assets/stylesheets
<ruby-gems-path>//.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_elements_rails-3.1.2/vendor/assets/stylesheets
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_frontend_toolkit-7.4.2/app/assets/docs
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_frontend_toolkit-7.4.2/app/assets/images
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_frontend_toolkit-7.4.2/app/assets/javascripts
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_frontend_toolkit-7.4.2/app/assets/spec
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_frontend_toolkit-7.4.2/app/assets/stylesheets
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_template-0.23.1/app/assets/images
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_template-0.23.1/app/assets/javascripts
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/govuk_template-0.23.1/app/assets/stylesheets
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/gov_uk_date_fields-2.1.1/vendor/assets/javascripts
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/gov_uk_date_fields-2.1.1/vendor/assets/stylesheets
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/actioncable-5.0.7/lib/assets/compiled
<rails_app_root>/vendor/assets/images
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/susy-2.2.14/sass
<ruby-gems-path>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/susy-2.2.14/sass:

Would it be possible to add the frontend-toolkit file to its gem so it can be loaded correctly? (I've noticed that in dev mode the gem seems to work as the source code has a git submodule linked to the actual govuk_elements source code where the frontend-toolkit file does exist.

36degrees commented 6 years ago

Hi Sergio,

Thanks for raising this. I've been able to reproduce this – it looks like that failing include is actually trying to import this file from Elements.

However, if you include the component parts of Frontend Toolkit and Elements as per the example in the readme it should work fine – with one exception:

@import 'elements/forms/form-block-labels'
@import 'elements/forms/form-date'
@import 'elements/forms/form-validation'

should be

@import 'elements/forms/form-date';
@import 'elements/forms/form-multiple-choice';
@import 'elements/forms/form-validation';

I'll raise a PR to update those docs now, and that should work fine for you. In the meantime, I'll try and dig in and work out why @import govuk-elements doesn't work.

36degrees commented 5 years ago

I'm closing this as I believe it was addressed by #34.