Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fde1edf

Browse files
SebouChuglebm
authored andcommittedAug 17, 2023
Soft-dependency to Sass to allow Dart Sass
1 parent 07f432e commit fde1edf

13 files changed

+47
-14
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: CI
22

33
on:
4-
push:
5-
pull_request:
4+
- push
5+
- pull_request
6+
- workflow_dispatch
67

78
jobs:
89
test:
@@ -18,17 +19,22 @@ jobs:
1819
- test/gemfiles/rails_5_2.gemfile
1920
- test/gemfiles/rails_6_0.gemfile
2021
- test/gemfiles/rails_6_1.gemfile
21-
- test/gemfiles/rails_7_0.gemfile
22+
- test/gemfiles/rails_7_0_sassc.gemfile
23+
- test/gemfiles/rails_7_0_dartsass.gemfile
2224
include:
2325
- ruby_version: '2.5'
2426
gemfile: test/gemfiles/rails_4_2.gemfile
2527
- ruby_version: '2.6'
2628
gemfile: test/gemfiles/rails_4_2.gemfile
2729
exclude:
2830
- ruby_version: '2.5'
29-
gemfile: test/gemfiles/rails_7_0.gemfile
31+
gemfile: test/gemfiles/rails_7_0_sassc.gemfile
32+
- ruby_version: '2.5'
33+
gemfile: test/gemfiles/rails_7_0_dartsass.gemfile
34+
- ruby_version: '2.6'
35+
gemfile: test/gemfiles/rails_7_0_sassc.gemfile
3036
- ruby_version: '2.6'
31-
gemfile: test/gemfiles/rails_7_0.gemfile
37+
gemfile: test/gemfiles/rails_7_0_dartsass.gemfile
3238
- ruby_version: '3.0'
3339
gemfile: test/gemfiles/rails_5_0.gemfile
3440
- ruby_version: '3.0'

‎README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ Add `bootstrap` to your Gemfile:
2424
gem 'bootstrap', '~> 5.3.1'
2525
```
2626

27-
Ensure that `sprockets-rails` is at least v2.3.2.
27+
This gem requires a Sass engine, so make sure you have **one** of these two gems in your Gemfile:
28+
- [`dartsass-sprockets`](https://github.com/tablecheck/dartsass-sprockets): Dart Sass engine, recommended but only works for Ruby 2.6+ and Rails 5+
29+
- [`sassc-rails`](https://github.com/sass/sassc-rails): SassC engine, deprecated but compatible with Ruby 2.3+ and Rails 4
30+
31+
Also ensure that `sprockets-rails` is at least v2.3.2.
2832

2933
`bundle install` and restart your server to make the files available through the pipeline.
3034

‎Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@ end
4545

4646
desc 'Dumps output to a CSS file for testing'
4747
task :debug do
48-
require 'sassc'
48+
begin
49+
require 'dartsass-ruby'
50+
rescue LoadError
51+
require 'sassc'
52+
rescue LoadError
53+
raise LoadError.new("bootstrap-rubygem requires a Sass engine. Please add dartsass-sprockets or sassc-rails to your dependencies.")
54+
end
4955
require './lib/bootstrap'
5056
require 'term/ansicolor'
5157
require 'autoprefixer-rails'
5258
path = Bootstrap.stylesheets_path
5359
%w(_bootstrap _bootstrap-reboot _bootstrap-grid).each do |file|
60+
# For ease of upgrading, the root namespace ::SassC is still used by dartsass-sprockets.
61+
# This is planned to be renamed in a future major version release.
5462
engine = SassC::Engine.new(File.read("#{path}/#{file}.scss"), syntax: :scss, load_paths: [path])
5563
out = File.join('tmp', "#{file[1..-1]}.css")
5664
css = engine.render

‎bootstrap.gemspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ Gem::Specification.new do |s|
1515
s.required_ruby_version = '>= 2.3.3'
1616

1717
s.add_runtime_dependency 'popper_js', '>= 2.11.8', '< 3'
18-
19-
s.add_runtime_dependency 'sassc-rails', '>= 2.0.0'
2018
s.add_runtime_dependency 'autoprefixer-rails', '>= 9.1.0'
2119

2220
# Testing dependencies

‎lib/bootstrap/engine.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# frozen_string_literal: true
22

33
require 'autoprefixer-rails'
4-
require 'sassc-rails'
4+
begin
5+
require 'dartsass-sprockets'
6+
rescue LoadError
7+
require 'sassc-rails'
8+
rescue LoadError
9+
raise LoadError.new("bootstrap-rubygem requires a Sass engine. Please add dartsass-sprockets or sassc-rails to your dependencies.")
10+
end
511

612
module Bootstrap
713
module Rails

‎test/gemfiles/rails_4_2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ source 'https://rubygems.org'
22

33
gem 'actionpack', '~> 4.2.7'
44
gem 'activesupport', '~> 4.2.7'
5+
gem 'sassc-rails', '~> 2.0'
56

67
gemspec path: '../../'
7-

‎test/gemfiles/rails_5_0.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 5.0.0'
44
gem 'activesupport', '~> 5.0.0'
55
gem 'autoprefixer-rails', '>= 6.3.6.1'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'
8-

‎test/gemfiles/rails_5_1.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 5.1.0'
44
gem 'activesupport', '~> 5.1.0'
55
gem 'autoprefixer-rails', '>= 7.1.1'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'
8-

‎test/gemfiles/rails_5_2.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 5.2.8'
44
gem 'activesupport', '~> 5.2.8'
55
gem 'autoprefixer-rails', '>= 7.1.1'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'
8-

‎test/gemfiles/rails_6_0.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 6.0.3'
44
gem 'activesupport', '~> 6.0.3'
55
gem 'autoprefixer-rails', '>= 9.7.6'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'

‎test/gemfiles/rails_6_1.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 6.1.3'
44
gem 'activesupport', '~> 6.1.3'
55
gem 'autoprefixer-rails', '>= 9.7.6'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'actionpack', '~> 7.0.4'
4+
gem 'activesupport', '~> 7.0.4'
5+
gem 'autoprefixer-rails', '>= 9.7.6'
6+
gem 'dartsass-sprockets', '~> 3.0'
7+
8+
gemspec path: '../../'

‎test/gemfiles/rails_7_0.gemfile renamed to ‎test/gemfiles/rails_7_0_sassc.gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
33
gem 'actionpack', '~> 7.0.4'
44
gem 'activesupport', '~> 7.0.4'
55
gem 'autoprefixer-rails', '>= 9.7.6'
6+
gem 'sassc-rails', '~> 2.0'
67

78
gemspec path: '../../'

0 commit comments

Comments
 (0)
Please sign in to comment.