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

Migrate from SassC to Dart Sass #313

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jvendetti
Copy link
Member

This pull request migrates from SassC to Dart Sass, and was motivated by two main factors: 1) SassC is deprecated, and 2) a recent attempt to integrate styles from the tom-select plug-in failed (see #312). The comments in Migration from sassc-rails workarounds issue were particularly useful.

Changes include:

  • Replace the sassc-rails gem with dartsass-rails
  • Migrate style files to the default Sass input file: app/assets/stylesheets/application.scss
  • Change from @import to the @use rule in the default input file
  • Separate out the jquery-ui styles and process with Sprockets. The jquery-ui-rails gem depends on Sprockets require directives, which aren't supported in dartsass-rails.
  • Fix "There's already a module with namespace" errors by adding as clauses
  • Replace image-url asset helpers with url, as dartsass-rails doesn't support asset helpers

The jquery-ui-rails gem uses Sprockets require directives, which are incompatible with dartsass-rails.
This file is replaced by the dartsass-rails default input file at app/assets/stylesheets/application.scss.
dartsass-rails doesn't support asset helper methods
@jvendetti jvendetti self-assigned this Apr 12, 2024
@jvendetti
Copy link
Member Author

After pursuing this approach, I'm not convinced that integrating this code is advisable. We've already committed to jsbundling-rails, making cssbundling-rails the logical choice for asset management.

In addition, migrating to dartsass-rails doesn't entirely solve issues related to processing style files from 3rd-party libraries. I re-tested adding tom-select after the migration and their Bootstrap-specific styles still result in errors. For example, adding this line at the bottom of the default input file:

@use 'tom-select/dist/scss/tom-select.bootstrap5'

Results in a build failure:

Error: Undefined variable.

$state-valid: map-get($form-validation-states,'valid') !default;

This variable does in fact exist in the gem:

$ bootstrap-5.2.3 grep -R "\$form-validation-states"
./assets/stylesheets/bootstrap/_variables.scss:$form-validation-states: (

... and I believe the build failure is attributable to an ordering issue, similar to what's described here: rails/dartsass-rails#43 (comment).

@syphax-bouazzouni
Copy link
Contributor

syphax-bouazzouni commented Apr 13, 2024

Hello,

Just for note, maybe not related; but we still use Bootstrap 4.3 in Agroportal and maybe that is why make tom-select work, and maybe will we have those same issues when migrating to Bootstrap 5.

In the matter of migrating to Dart Sass, I also tried to do it some time ago but did not work, cssbundling-rails agree that it would be the final goal, but will take some time, as we still use JQuery / JQuery UI and other stuff using the traditional assets pipeline.

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

Successfully merging this pull request may close these issues.

2 participants