Skip to content

Commit

Permalink
Merge pull request #2709 from alphagov/use-dartsass-rails-vs-sassc-rails
Browse files Browse the repository at this point in the history
Use dartsass-rails vs sassc-rails
  • Loading branch information
floehopper authored Feb 13, 2024
2 parents 6679779 + dc16605 commit ee40432
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ yarn-error.log

# Ignore compiled Rails assets
/public/assets

# For dartsass-rails
/app/assets/builds/*
!/app/assets/builds/.keep
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem "addressable"
gem "ancestry"
gem "bootsnap", require: false
gem "browser"
gem "dartsass-rails"
gem "devise"
gem "devise-encryptable"
gem "devise_invitable"
Expand All @@ -24,7 +25,6 @@ gem "rails-html-sanitizer"
gem "rake"
gem "rotp"
gem "rqrcode"
gem "sassc-rails"
gem "sentry-sidekiq"
gem "sprockets-rails"
gem "uglifier"
Expand Down
23 changes: 13 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ GEM
bigdecimal
rexml
crass (1.0.6)
dartsass-rails (0.5.0)
railties (>= 6.0.0)
sass-embedded (~> 1.63)
date (3.3.4)
debug_inspector (1.2.0)
devise (4.9.3)
Expand Down Expand Up @@ -609,14 +612,15 @@ GEM
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
sass-embedded (1.70.0)
google-protobuf (~> 3.25)
rake (>= 13.0.0)
sass-embedded (1.70.0-aarch64-linux-gnu)
google-protobuf (~> 3.25)
sass-embedded (1.70.0-arm64-darwin)
google-protobuf (~> 3.25)
sass-embedded (1.70.0-x86_64-linux-gnu)
google-protobuf (~> 3.25)
selenium-webdriver (4.17.0)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
Expand Down Expand Up @@ -651,7 +655,6 @@ GEM
statsd-ruby (1.5.0)
systemu (2.6.5)
thor (1.3.0)
tilt (2.3.0)
timecop (0.9.8)
timeout (0.4.1)
tzinfo (2.0.6)
Expand Down Expand Up @@ -696,6 +699,7 @@ DEPENDENCIES
capybara
capybara-email
climate_control
dartsass-rails
devise
devise-encryptable
devise_invitable
Expand Down Expand Up @@ -727,7 +731,6 @@ DEPENDENCIES
rotp
rqrcode
rubocop-govuk
sassc-rails
sentry-sidekiq
shoulda-context
simplecov
Expand Down
2 changes: 2 additions & 0 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bin/rails server -p 3000
css: bin/rails dartsass:watch
5 changes: 0 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@ require File.expand_path("config/application", __dir__)

Signon::Application.load_tasks

require "sprockets/rails/task"
Sprockets::Rails::Task.new(Rails.application) do |t|
t.log_level = Logger::WARN
end

Rake::Task[:default].clear_prerequisites
task default: %i[lint jasmine test]
Empty file added app/assets/builds/.keep
Empty file.
2 changes: 1 addition & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//= link_tree ../images
//= link application.css
//= link_tree ../builds
//= link application.js
3 changes: 2 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ $govuk-page-width: 1140px;
@import "user_research_recruitment_banner";

// Components from this application
@import "components/*";
@import "components/contact-details";
@import "components/table";

// TODO: move into component
.gem-c-success-alert,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $vertical-on-smallscreen-breakpoint: 940px;
$sort-link-active-colour: govuk-colour("white");
$sort-link-arrow-size: 14px;
$sort-link-arrow-size-small: 8px;
$sort-link-arrow-spacing: $sort-link-arrow-size / 2;
$sort-link-arrow-spacing: calc($sort-link-arrow-size / 2);
$table-row-hover-background-colour: rgba(43, 140, 196, .2);
$table-row-even-background-colour: govuk-colour("light-grey", $legacy: "grey-4");

Expand Down
6 changes: 6 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
if ! gem list foreman -i --silent; then
echo "Installing foreman..."
gem install foreman
fi
exec foreman start -f Procfile.dev "$@"
4 changes: 4 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
# Suppress logger output for asset requests.
config.assets.quiet = true

# Disable digest to see the latest stylesheet changes when running Sass in watch mode
# See https://guides.rubyonrails.org/v7.1.3/asset_pipeline.html#turning-digests-off
config.assets.digest = false

# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

Expand Down
3 changes: 0 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass

# Do not add source map line comments into css files
config.sass.line_comments = false

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

Expand Down
1 change: 1 addition & 0 deletions config/initializers/dartsass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rails.application.config.dartsass.build_options << " --quiet-deps"
6 changes: 6 additions & 0 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "sprockets/rails/task"
Sprockets::Rails::Task.new(Rails.application) do |t|
t.log_level = Logger::WARN
end

Rake::Task["assets:precompile"].enhance(["dartsass:build"])

0 comments on commit ee40432

Please sign in to comment.