dartsass-sprockets 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +75 -14
- data/lib/dartsass-sprockets.rb +1 -1
- data/lib/rails/generators/sass/assets/assets_generator.rb +5 -3
- data/lib/rails/generators/sass/scaffold/scaffold_generator.rb +6 -2
- data/lib/rails/generators/sass_scaffold.rb +5 -3
- data/lib/rails/generators/scss/assets/assets_generator.rb +5 -3
- data/lib/rails/generators/scss/scaffold/scaffold_generator.rb +6 -3
- data/lib/sassc/rails/compressor.rb +13 -25
- data/lib/sassc/rails/functions.rb +2 -2
- data/lib/sassc/rails/importer.rb +27 -27
- data/lib/sassc/rails/railtie.rb +57 -57
- data/lib/sassc/rails/template.rb +84 -88
- data/lib/sassc/rails/version.rb +1 -1
- data/lib/sassc/rails.rb +7 -7
- metadata +20 -75
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97ecd8e6a0a54de66fe07748636aa80c19d0a15e61259cf84fa4176bab3299f2
|
|
4
|
+
data.tar.gz: 05040dc70d0af1710fd6e6525912fe684fdd12c09aae41b8e6784ab0c9677d1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef8f73113bc5107745a3339297790c4ed857ed961c8d1935982fd9a5e05f0f35d66403db69b1f76bce7c2edfce3123a7e60d8df6af1ec970896499220fed08d4
|
|
7
|
+
data.tar.gz: 1b82505cf1465ade855b79fd954a7047943600a0fc26ae25643f934768974db8441cdb2d44f2522a8f4d169cb4fe8b0432fa0196385df20fd4b61532823ad03a
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Use [Dart Sass](https://sass-lang.com/dart-sass) with Sprockets and the Ruby on
|
|
|
7
7
|
|
|
8
8
|
This gem is a fork of [sass/sassc-rails](https://github.com/sass/sassc-rails)
|
|
9
9
|
which maintains API compatibility but delegates to the
|
|
10
|
-
[
|
|
10
|
+
[sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem
|
|
11
11
|
which uses Dart Sass instead of the libsass C implmentation.
|
|
12
12
|
|
|
13
13
|
For ease of upgrading, the root namespace `::SassC` is still used by this gem,
|
|
@@ -25,29 +25,87 @@ gem 'dartsass-sprockets'
|
|
|
25
25
|
This will automatically configure your default Rails
|
|
26
26
|
`config.assets.css_compressor` to use `:sass`.
|
|
27
27
|
|
|
28
|
-
###
|
|
28
|
+
### Version Support
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
The current version of `dartsass-sprockets` supports:
|
|
31
|
+
- Ruby 3.1+
|
|
32
|
+
- Rails 6.1+
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
For older versions of Ruby and Rails may be supported with earlier versions of this gem.
|
|
35
|
+
|
|
36
|
+
## CSS Minification (Production)
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
This gem uses a Railtie to automatically set the following
|
|
39
|
+
configuration in all environments *except* Development:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
# set automatically by this gem
|
|
43
|
+
config.assets.css_compressor = :sass
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This causes Sprockets to minify *all* CSS assets (both Sass and plain CSS) using Dart Sass.
|
|
47
|
+
This minification is done as a *second-pass* after compiling the Sass to CSS,
|
|
48
|
+
and is done irrespective of whether the `config.sass.style` option is set to `:compressed`.
|
|
49
|
+
To disable this behavior, set `config.assets.css_compressor = false`.
|
|
50
|
+
|
|
51
|
+
## Source Maps (Development)
|
|
37
52
|
|
|
38
53
|
To turn on inline source maps, add the following configuration
|
|
39
|
-
to your `development.rb` file:
|
|
54
|
+
to your `config/environments/development.rb` file:
|
|
40
55
|
|
|
41
56
|
```ruby
|
|
42
|
-
# config/environments/development.rb
|
|
57
|
+
# in config/environments/development.rb
|
|
43
58
|
config.sass.inline_source_maps = true
|
|
44
59
|
```
|
|
45
60
|
|
|
46
|
-
|
|
47
|
-
(
|
|
61
|
+
Note these source maps appended *inline* to the compiled `application.css` file.
|
|
62
|
+
(This option will *not* generate additional files.)
|
|
63
|
+
|
|
64
|
+
## Silencing Deprecation Warnings
|
|
65
|
+
|
|
66
|
+
To silence common deprecation warnings, add the following
|
|
67
|
+
configuration. Refer to details in the below section.
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
# in config/application.rb
|
|
71
|
+
config.sass.quiet_deps = true
|
|
72
|
+
config.sass.silence_deprecations = ['import']
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Advanced Configuration
|
|
76
|
+
|
|
77
|
+
The following options are exposed via `Rails.application.config.sass.{option}`.
|
|
78
|
+
Options denoted with * are handed by the sass-embedded gem and passed into Dart Sass;
|
|
79
|
+
refer to [the sass-embedded documentation](https://rubydoc.info/gems/sass-embedded/Sass)
|
|
80
|
+
and the [Dart Sass documentation](https://sass-lang.com/documentation/js-api/interfaces/options/).
|
|
81
|
+
|
|
82
|
+
| Option | Type | Description |
|
|
83
|
+
|-------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------|
|
|
84
|
+
| `load_paths` | `Array<String>` | Additional paths to look for imported files. |
|
|
85
|
+
| `inline_source_maps` | `Boolean` | If `true`, will append source maps inline to the generated CSS file. Refer to section below. |
|
|
86
|
+
| `style`* | `Symbol` | `:expanded` (default) or `:compressed`. See note about CSS Minification below. |
|
|
87
|
+
| `charset`* | `Boolean` | Whether to include a @charset declaration or byte-order mark in the CSS output (default `true`). |
|
|
88
|
+
| `logger`* | `Object` | An object to use to handle warnings and/or debug messages from Sass. |
|
|
89
|
+
| `alert_ascii`* | `Boolean` | If `true`, Dart Sass will exclusively use ASCII characters in its error and warning messages (default `false`). |
|
|
90
|
+
| `alert_color`* | `Boolean` | If `true`, Dart Sass will use ANSI color escape codes in its error and warning messages (default `false`). |
|
|
91
|
+
| `verbose`* | `Boolean` | By default (`false`) Dart Sass logs up to five occurrences of each deprecation warning. Setting to `true` removes this limit. |
|
|
92
|
+
| `quiet_deps`* | `Boolean` | If `true`, Dart Sass won’t print warnings that are caused by dependencies (default `false`). |
|
|
93
|
+
| `silence_deprecations`* | `Array<String>` | An array of active deprecations to ignore. Refer to (deprecations)[dartsass-deprecations]. |
|
|
94
|
+
| `fatal_deprecations`* | `Array<String>` | An array of deprecations to treat as fatal. Refer to (deprecations)[dartsass-deprecations]. |
|
|
95
|
+
| `future_deprecations`* | `Array<String>` | An array of future deprecations to opt-into early. Refer to (deprecations)[dartsass-deprecations]. |
|
|
96
|
+
| `importers`* | `Array<Object>` | Custom importers to use when resolving `@import` directives. |
|
|
97
|
+
|
|
98
|
+
When changing config options in Development environment, you may need to clear
|
|
99
|
+
your assets cache (`rm -r tmp/cache/assets`) and restart your Rails server.
|
|
100
|
+
|
|
101
|
+
### Upgrading from Legacy Sass Rails
|
|
48
102
|
|
|
49
|
-
|
|
50
|
-
|
|
103
|
+
This gem is a drop-in replacement to [sass-rails](https://github.com/rails/sass-rails).
|
|
104
|
+
Note the following differences:
|
|
105
|
+
|
|
106
|
+
* This library does not apply SASS processing to `.css` files. Please ensure all your SASS files have file extension `.scss`.
|
|
107
|
+
* `config.sass.style` values `:nested` and `:compact` will behave as `:expanded`. Use `:compressed` for minification.
|
|
108
|
+
* `config.sass.line_comments` option is ignored and will always be disabled.
|
|
51
109
|
|
|
52
110
|
## Alternatives
|
|
53
111
|
|
|
@@ -58,10 +116,11 @@ Note these source maps are *inline* and will be appended to the compiled
|
|
|
58
116
|
## Credits
|
|
59
117
|
|
|
60
118
|
* This gem is maintained and used in production by [TableCheck](https://www.tablecheck.com/en/join). (We'd be very glad if the Sass organization could take over maintainership in the future!)
|
|
119
|
+
* Thank you to [Natsuki](https://ntk.me) for the [sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem.
|
|
61
120
|
* Credit to [Ryan Boland](https://ryanboland.com) and the authors of the original
|
|
62
121
|
[sass/sassc-rails](https://github.com/sass/sassc-rails) and
|
|
63
122
|
[sass-rails](https://github.com/rails/sass-rails) gems.
|
|
64
|
-
* See our [awesome contributors](https://github.com/tablecheck/
|
|
123
|
+
* See our [awesome contributors](https://github.com/tablecheck/dartsass-sprockets/graphs/contributors).
|
|
65
124
|
|
|
66
125
|
### Contributing
|
|
67
126
|
|
|
@@ -70,3 +129,5 @@ Note these source maps are *inline* and will be appended to the compiled
|
|
|
70
129
|
3. Commit your changes (`git commit -am 'Add some feature'`) - try to include tests
|
|
71
130
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
72
131
|
5. Create a new Pull Request
|
|
132
|
+
|
|
133
|
+
[dartsass-deprecations]: https://github.com/sass/sass/blob/40c50cb/js-api-doc/deprecations.d.ts#L260
|
data/lib/dartsass-sprockets.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/named_base'
|
|
2
4
|
|
|
3
5
|
module Sass
|
|
4
6
|
module Generators
|
|
5
7
|
class AssetsGenerator < ::Rails::Generators::NamedBase
|
|
6
|
-
source_root File.expand_path(
|
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
|
7
9
|
|
|
8
10
|
def copy_sass
|
|
9
|
-
template
|
|
11
|
+
template 'stylesheet.sass', File.join('app/assets/stylesheets', class_path, "#{file_name}.sass")
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/sass_scaffold'
|
|
2
4
|
|
|
3
5
|
module Sass
|
|
4
6
|
module Generators
|
|
5
7
|
class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
|
|
6
|
-
def syntax
|
|
8
|
+
def syntax
|
|
9
|
+
:sass
|
|
10
|
+
end
|
|
7
11
|
end
|
|
8
12
|
end
|
|
9
13
|
end
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'sassc/engine'
|
|
4
|
+
require 'rails/generators/named_base'
|
|
3
5
|
|
|
4
6
|
module Sass
|
|
5
7
|
module Generators
|
|
6
8
|
class ScaffoldBase < ::Rails::Generators::NamedBase
|
|
7
9
|
def copy_stylesheet
|
|
8
10
|
dir = ::Rails::Generators::ScaffoldGenerator.source_root
|
|
9
|
-
file = File.join(dir,
|
|
11
|
+
file = File.join(dir, 'scaffold.css')
|
|
10
12
|
converted_contents = ::SassC::Engine.new(File.read(file)).render
|
|
11
13
|
create_file "app/assets/stylesheets/scaffolds.#{syntax}", converted_contents
|
|
12
14
|
end
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/named_base'
|
|
2
4
|
|
|
3
5
|
module Scss
|
|
4
6
|
module Generators
|
|
5
7
|
class AssetsGenerator < ::Rails::Generators::NamedBase
|
|
6
|
-
source_root File.expand_path(
|
|
8
|
+
source_root File.expand_path('templates', __dir__)
|
|
7
9
|
|
|
8
10
|
def copy_scss
|
|
9
|
-
template
|
|
11
|
+
template 'stylesheet.scss', File.join('app/assets/stylesheets', class_path, "#{file_name}.scss")
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
14
|
end
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/sass_scaffold'
|
|
2
4
|
|
|
3
5
|
module Scss
|
|
4
6
|
module Generators
|
|
5
7
|
class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
|
|
6
|
-
def syntax
|
|
8
|
+
def syntax
|
|
9
|
+
:scss
|
|
10
|
+
end
|
|
7
11
|
end
|
|
8
12
|
end
|
|
9
13
|
end
|
|
10
|
-
|
|
@@ -3,32 +3,20 @@
|
|
|
3
3
|
require 'sprockets/sass_compressor'
|
|
4
4
|
require 'securerandom'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def call(*args)
|
|
18
|
-
input = if defined?(data)
|
|
19
|
-
data # sprockets 2.x
|
|
20
|
-
else
|
|
21
|
-
args[0][:data] #sprockets 3.x
|
|
6
|
+
module Sprockets
|
|
7
|
+
class SassCompressor
|
|
8
|
+
def initialize(options = {})
|
|
9
|
+
@options = {
|
|
10
|
+
syntax: :scss,
|
|
11
|
+
cache: false,
|
|
12
|
+
read_cache: false,
|
|
13
|
+
style: :compressed
|
|
14
|
+
}.merge(options).freeze
|
|
15
|
+
@cache_key = SecureRandom.uuid
|
|
22
16
|
end
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
style: :compressed
|
|
28
|
-
}
|
|
29
|
-
).render
|
|
18
|
+
def call(*args)
|
|
19
|
+
SassC::Engine.new(args[0][:data], { style: :compressed }).render
|
|
20
|
+
end
|
|
30
21
|
end
|
|
31
|
-
|
|
32
|
-
# sprockets 2.x
|
|
33
|
-
alias :evaluate :call
|
|
34
22
|
end
|
|
@@ -5,9 +5,9 @@ require 'sprockets/sass_functions'
|
|
|
5
5
|
module Sprockets
|
|
6
6
|
module SassFunctions
|
|
7
7
|
def asset_data_url(path)
|
|
8
|
-
::SassC::Script::Value::String.new("url(
|
|
8
|
+
::SassC::Script::Value::String.new("url(#{sprockets_context.asset_data_uri(path.value)})")
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
SassC::Script::Functions.include Sprockets::SassFunctions
|
data/lib/sassc/rails/importer.rb
CHANGED
|
@@ -8,44 +8,44 @@ module SassC
|
|
|
8
8
|
class Extension
|
|
9
9
|
attr_reader :postfix
|
|
10
10
|
|
|
11
|
-
def initialize(postfix=nil)
|
|
11
|
+
def initialize(postfix = nil)
|
|
12
12
|
@postfix = postfix
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def import_for(full_path,
|
|
15
|
+
def import_for(full_path, _parent_dir, _options)
|
|
16
16
|
SassC::Importer::Import.new(full_path)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
class CSSExtension
|
|
21
21
|
def postfix
|
|
22
|
-
|
|
22
|
+
'.css'
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def import_for(full_path,
|
|
26
|
-
import_path = full_path.gsub(/\.css$/,
|
|
25
|
+
def import_for(full_path, _parent_dir, _options)
|
|
26
|
+
import_path = full_path.gsub(/\.css$/, '')
|
|
27
27
|
SassC::Importer::Import.new(import_path)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
class CssScssExtension < Extension
|
|
32
32
|
def postfix
|
|
33
|
-
|
|
33
|
+
'.css.scss'
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def import_for(full_path,
|
|
37
|
-
source = File.
|
|
36
|
+
def import_for(full_path, _parent_dir, _options)
|
|
37
|
+
source = File.binread(full_path)
|
|
38
38
|
SassC::Importer::Import.new(full_path, source: source)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
class CssSassExtension < Extension
|
|
43
43
|
def postfix
|
|
44
|
-
|
|
44
|
+
'.css.sass'
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def import_for(full_path,
|
|
48
|
-
sass = File.
|
|
47
|
+
def import_for(full_path, _parent_dir, _options)
|
|
48
|
+
sass = File.binread(full_path)
|
|
49
49
|
parsed_scss = SassC::Sass2Scss.convert(sass)
|
|
50
50
|
SassC::Importer::Import.new(full_path, source: parsed_scss)
|
|
51
51
|
end
|
|
@@ -53,10 +53,10 @@ module SassC
|
|
|
53
53
|
|
|
54
54
|
class SassERBExtension < Extension
|
|
55
55
|
def postfix
|
|
56
|
-
|
|
56
|
+
'.sass.erb'
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
-
def import_for(full_path,
|
|
59
|
+
def import_for(full_path, _parent_dir, options)
|
|
60
60
|
template = Tilt::ERBTemplate.new(full_path)
|
|
61
61
|
parsed_erb = template.render(options[:sprockets][:context], {})
|
|
62
62
|
parsed_scss = SassC::Sass2Scss.convert(parsed_erb)
|
|
@@ -65,7 +65,7 @@ module SassC
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
class ERBExtension < Extension
|
|
68
|
-
def import_for(full_path,
|
|
68
|
+
def import_for(full_path, _parent_dir, options)
|
|
69
69
|
template = Tilt::ERBTemplate.new(full_path)
|
|
70
70
|
parsed_erb = template.render(options[:sprockets][:context], {})
|
|
71
71
|
SassC::Importer::Import.new(full_path, source: parsed_erb)
|
|
@@ -76,29 +76,29 @@ module SassC
|
|
|
76
76
|
CssScssExtension.new,
|
|
77
77
|
CssSassExtension.new,
|
|
78
78
|
SassERBExtension.new,
|
|
79
|
-
ERBExtension.new(
|
|
80
|
-
ERBExtension.new(
|
|
81
|
-
Extension.new(
|
|
82
|
-
Extension.new(
|
|
79
|
+
ERBExtension.new('.scss.erb'),
|
|
80
|
+
ERBExtension.new('.css.erb'),
|
|
81
|
+
Extension.new('.scss'),
|
|
82
|
+
Extension.new('.sass'),
|
|
83
83
|
CSSExtension.new
|
|
84
84
|
].freeze
|
|
85
85
|
|
|
86
|
-
PREFIXS = [
|
|
87
|
-
GLOB =
|
|
86
|
+
PREFIXS = ['', '_'].freeze
|
|
87
|
+
GLOB = %r{(\A|/)(\*|\*\*/\*)\z}
|
|
88
88
|
|
|
89
89
|
def imports(path, parent_path)
|
|
90
|
-
parent_dir,
|
|
90
|
+
parent_dir, = File.split(parent_path)
|
|
91
91
|
specified_dir, specified_file = File.split(path)
|
|
92
92
|
|
|
93
|
-
if m = path.match(GLOB)
|
|
94
|
-
path = path.sub(m[0],
|
|
93
|
+
if (m = path.match(GLOB))
|
|
94
|
+
path = path.sub(m[0], '')
|
|
95
95
|
base = File.expand_path(path, File.dirname(parent_path))
|
|
96
96
|
return glob_imports(base, m[2], parent_path)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
search_paths = ([parent_dir] + load_paths).uniq
|
|
100
100
|
|
|
101
|
-
if specified_dir !=
|
|
101
|
+
if specified_dir != '.'
|
|
102
102
|
search_paths.map! do |path|
|
|
103
103
|
File.join(path, specified_dir)
|
|
104
104
|
end
|
|
@@ -157,15 +157,15 @@ module SassC
|
|
|
157
157
|
|
|
158
158
|
def globbed_files(base, glob)
|
|
159
159
|
# TODO: Raise an error from SassC here
|
|
160
|
-
raise ArgumentError unless
|
|
160
|
+
raise ArgumentError unless ['*', '**/*'].include?(glob)
|
|
161
161
|
|
|
162
162
|
extensions = EXTENSIONS.map(&:postfix)
|
|
163
|
-
exts = extensions.map { |ext| Regexp.escape(
|
|
163
|
+
exts = extensions.map { |ext| Regexp.escape(ext.to_s) }.join('|')
|
|
164
164
|
sass_re = Regexp.compile("(#{exts})$")
|
|
165
165
|
|
|
166
166
|
record_import_as_dependency(base)
|
|
167
167
|
|
|
168
|
-
files = Dir["#{base}/#{glob}"].
|
|
168
|
+
files = Dir["#{base}/#{glob}"].map do |path|
|
|
169
169
|
if File.directory?(path)
|
|
170
170
|
record_import_as_dependency(path)
|
|
171
171
|
nil
|
data/lib/sassc/rails/railtie.rb
CHANGED
|
@@ -3,78 +3,78 @@
|
|
|
3
3
|
require 'active_support/core_ext/class/attribute'
|
|
4
4
|
require 'sprockets/railtie'
|
|
5
5
|
|
|
6
|
-
module SassC
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
module SassC
|
|
7
|
+
module Rails
|
|
8
|
+
class Railtie < ::Rails::Railtie
|
|
9
|
+
config.sass = ActiveSupport::OrderedOptions.new
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# Initialize the load paths to an empty array
|
|
14
|
-
config.sass.load_paths = []
|
|
11
|
+
# Establish static configuration defaults
|
|
12
|
+
# Emit scss files during stylesheet generation of scaffold
|
|
13
|
+
config.sass.preferred_syntax = :scss
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
# Initialize the load paths to an empty array
|
|
16
|
+
config.sass.load_paths = []
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# --stylesheet_engine=sass
|
|
22
|
-
# to the rails generate command
|
|
23
|
-
config.app_generators.stylesheet_engine config.sass.preferred_syntax
|
|
18
|
+
# Silence deprecation warnings during compilation that come from dependencies
|
|
19
|
+
config.sass.quiet_deps = false
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
# Set the default stylesheet engine
|
|
22
|
+
# It can be overridden by passing:
|
|
23
|
+
# --stylesheet_engine=sass
|
|
24
|
+
# to the rails generate command
|
|
25
|
+
config.app_generators.stylesheet_engine config.sass.preferred_syntax
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
end
|
|
27
|
+
if config.respond_to?(:annotations)
|
|
28
|
+
config.annotations.register_extensions('scss', 'sass') { |annotation| %r{//\s*(#{annotation}):?\s*(.*)$} }
|
|
29
|
+
end
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
app.config.generators.hide_namespace alt_syntax
|
|
31
|
+
# Remove the sass middleware if it gets inadvertently enabled by applications.
|
|
32
|
+
config.after_initialize do |app|
|
|
33
|
+
app.config.middleware.delete(Sass::Plugin::Rack) if defined?(Sass::Plugin::Rack)
|
|
34
|
+
end
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
initializer :setup_sass, group: :all do |app|
|
|
37
|
+
# Only emit one kind of syntax because though we have registered two kinds of generators
|
|
38
|
+
syntax = app.config.sass.preferred_syntax.to_sym
|
|
39
|
+
alt_syntax = syntax == :sass ? 'scss' : 'sass'
|
|
40
|
+
app.config.generators.hide_namespace alt_syntax
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# # Display a stack trace in the css output when in development-like environments.
|
|
46
|
-
# config.sass.full_exception = app.config.consider_all_requests_local
|
|
47
|
-
# end
|
|
42
|
+
# Override stylesheet engine to the preferred syntax
|
|
43
|
+
config.app_generators.stylesheet_engine syntax
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
45
|
+
# Establish configuration defaults that are environmental in nature
|
|
46
|
+
# if config.sass.full_exception.nil?
|
|
47
|
+
# # Display a stack trace in the css output when in development-like environments.
|
|
48
|
+
# config.sass.full_exception = app.config.consider_all_requests_local
|
|
49
|
+
# end
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
env.
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
app.config.assets.configure do |env|
|
|
52
|
+
env.context_class.class_eval do
|
|
53
|
+
class_attribute :sass_config
|
|
54
|
+
self.sass_config = app.config.sass
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if env.respond_to?(:register_transformer)
|
|
58
|
+
env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new
|
|
59
|
+
env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new
|
|
60
|
+
end
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if env.respond_to?(:register_engine)
|
|
63
|
+
[
|
|
64
|
+
['.sass', SassC::Rails::SassTemplate],
|
|
65
|
+
['.scss', SassC::Rails::ScssTemplate]
|
|
66
|
+
].each do |engine|
|
|
67
|
+
engine << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
|
|
68
|
+
env.register_engine(*engine)
|
|
69
|
+
end
|
|
67
70
|
end
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
|
-
end
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# Use expanded output instead of the sass default of :nested unless specified
|
|
77
|
-
app.config.sass.style ||= :expanded
|
|
74
|
+
initializer :setup_compression, group: :all do |app|
|
|
75
|
+
unless ::Rails.env.development?
|
|
76
|
+
app.config.assets.css_compressor = :sass unless app.config.assets.key?(:css_compressor) # rubocop:disable Style/SoleNestedConditional
|
|
77
|
+
end
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
end
|
data/lib/sassc/rails/template.rb
CHANGED
|
@@ -1,113 +1,109 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'sprockets/version'
|
|
4
4
|
require 'sprockets/sass_processor'
|
|
5
|
-
require
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
require 'sprockets/utils'
|
|
6
|
+
require 'sprockets/uri_utils'
|
|
7
|
+
|
|
8
|
+
module SassC
|
|
9
|
+
module Rails
|
|
10
|
+
class SassTemplate < Sprockets::SassProcessor
|
|
11
|
+
PASS_THRU_OPTIONS = %i[
|
|
12
|
+
style
|
|
13
|
+
charset
|
|
14
|
+
importers
|
|
15
|
+
logger
|
|
16
|
+
alert_ascii
|
|
17
|
+
alert_color
|
|
18
|
+
verbose
|
|
19
|
+
quiet_deps
|
|
20
|
+
silence_deprecations
|
|
21
|
+
fatal_deprecations
|
|
22
|
+
future_deprecations
|
|
23
|
+
].freeze
|
|
24
|
+
|
|
25
|
+
def initialize(options = {}, &block) # rubocop:disable Lint/MissingSuper
|
|
26
|
+
@cache_version = options[:cache_version]
|
|
27
|
+
@cache_key = "#{self.class.name}:#{VERSION}:#{::SassC::VERSION}:#{@cache_version}"
|
|
28
|
+
@importer_class = options[:importer] || ::SassC::Rails::Importer
|
|
29
|
+
@sass_config = options[:sass_config] || {}
|
|
30
|
+
@functions = Module.new do
|
|
31
|
+
include ::SassC::Script::Functions
|
|
32
|
+
include Functions
|
|
33
|
+
include options[:functions] if options[:functions]
|
|
34
|
+
class_eval(&block) if block_given?
|
|
35
|
+
end
|
|
18
36
|
end
|
|
19
|
-
end
|
|
20
37
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
def call(input) # rubocop:disable Metrics/AbcSize
|
|
39
|
+
context = input[:environment].context_class.new(input)
|
|
40
|
+
|
|
41
|
+
options = {
|
|
42
|
+
load_paths: input[:environment].paths | (::Rails.application.config.sass.load_paths || []),
|
|
43
|
+
filename: input[:filename],
|
|
44
|
+
syntax: self.class.syntax,
|
|
45
|
+
functions: @functions,
|
|
46
|
+
importer: @importer_class,
|
|
47
|
+
sprockets: {
|
|
48
|
+
context: context,
|
|
49
|
+
environment: input[:environment],
|
|
50
|
+
dependencies: context.metadata[:dependency_paths]
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
|
-
}.merge!(config_options) { |key, left, right| safe_merge(key, left, right) }
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
PASS_THRU_OPTIONS.each do |option|
|
|
55
|
+
options[option] = ::Rails.application.config.sass.send(option)
|
|
56
|
+
end
|
|
38
57
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
if ::Rails.application.config.sass.inline_source_maps
|
|
59
|
+
options.merge!(source_map_file: '.',
|
|
60
|
+
source_map_embed: true,
|
|
61
|
+
source_map_contents: true)
|
|
62
|
+
end
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
end
|
|
64
|
+
engine = ::SassC::Engine.new(input[:data], options.compact)
|
|
45
65
|
|
|
46
|
-
|
|
47
|
-
opts = { style: sass_style, load_paths: load_paths }
|
|
66
|
+
css = engine.render
|
|
48
67
|
|
|
68
|
+
# Track all imported files
|
|
69
|
+
sass_dependencies = Set.new([input[:filename]])
|
|
70
|
+
engine.dependencies.map do |dependency|
|
|
71
|
+
sass_dependencies << dependency.options[:filename]
|
|
72
|
+
context.metadata[:dependencies] << Sprockets::URIUtils.build_file_digest_uri(dependency.options[:filename])
|
|
73
|
+
end
|
|
49
74
|
|
|
50
|
-
|
|
51
|
-
opts.merge!({
|
|
52
|
-
source_map_file: ".",
|
|
53
|
-
source_map_embed: true,
|
|
54
|
-
source_map_contents: true,
|
|
55
|
-
})
|
|
75
|
+
context.metadata.merge(data: css, sass_dependencies: sass_dependencies)
|
|
56
76
|
end
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
# The methods in the Functions module were copied here from sprockets in order to
|
|
79
|
+
# override the Value class names (e.g. ::SassC::Script::Value::String)
|
|
80
|
+
module Functions
|
|
81
|
+
def asset_path(path, options = {})
|
|
82
|
+
path = path.value
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
path, _, query, fragment = URI.split(path)[5..8]
|
|
85
|
+
path = sprockets_context.asset_path(path, options)
|
|
86
|
+
query = "?#{query}" if query
|
|
87
|
+
fragment = "##{fragment}" if fragment
|
|
64
88
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
89
|
+
::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
|
|
90
|
+
end
|
|
68
91
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
92
|
+
def asset_url(path, options = {})
|
|
93
|
+
::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
|
|
94
|
+
end
|
|
72
95
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(left + right).uniq
|
|
78
|
-
else
|
|
79
|
-
right
|
|
96
|
+
def asset_data_url(path)
|
|
97
|
+
url = sprockets_context.asset_data_uri(path.value)
|
|
98
|
+
::SassC::Script::Value::String.new("url(#{url})")
|
|
99
|
+
end
|
|
80
100
|
end
|
|
81
101
|
end
|
|
82
102
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
def asset_path(path, options = {})
|
|
87
|
-
path = path.value
|
|
88
|
-
|
|
89
|
-
path, _, query, fragment = URI.split(path)[5..8]
|
|
90
|
-
path = sprockets_context.asset_path(path, options)
|
|
91
|
-
query = "?#{query}" if query
|
|
92
|
-
fragment = "##{fragment}" if fragment
|
|
93
|
-
|
|
94
|
-
::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def asset_url(path, options = {})
|
|
98
|
-
::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def asset_data_url(path)
|
|
102
|
-
url = sprockets_context.asset_data_uri(path.value)
|
|
103
|
-
::SassC::Script::Value::String.new("url(" + url + ")")
|
|
103
|
+
class ScssTemplate < SassTemplate
|
|
104
|
+
def self.syntax
|
|
105
|
+
:scss
|
|
104
106
|
end
|
|
105
107
|
end
|
|
106
108
|
end
|
|
107
|
-
|
|
108
|
-
class ScssTemplate < SassTemplate
|
|
109
|
-
def self.syntax
|
|
110
|
-
:scss
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
109
|
end
|
data/lib/sassc/rails/version.rb
CHANGED
data/lib/sassc/rails.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative 'rails/version'
|
|
4
4
|
|
|
5
|
-
require
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
5
|
+
require 'sassc-embedded'
|
|
6
|
+
require_relative 'rails/functions'
|
|
7
|
+
require_relative 'rails/importer'
|
|
8
|
+
require_relative 'rails/template'
|
|
9
|
+
require_relative 'rails/compressor'
|
|
10
|
+
require_relative 'rails/railtie'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dartsass-sprockets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Boland
|
|
@@ -9,80 +9,52 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-01-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
requirements:
|
|
18
|
-
- - ">="
|
|
19
|
-
- !ruby/object:Gem::Version
|
|
20
|
-
version: '0'
|
|
21
|
-
type: :development
|
|
22
|
-
prerelease: false
|
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
-
requirements:
|
|
25
|
-
- - ">="
|
|
26
|
-
- !ruby/object:Gem::Version
|
|
27
|
-
version: '0'
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: bundler
|
|
15
|
+
name: railties
|
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
|
31
17
|
requirements:
|
|
32
18
|
- - ">="
|
|
33
19
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
35
|
-
type: :
|
|
20
|
+
version: 4.0.0
|
|
21
|
+
type: :runtime
|
|
36
22
|
prerelease: false
|
|
37
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
24
|
requirements:
|
|
39
25
|
- - ">="
|
|
40
26
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
27
|
+
version: 4.0.0
|
|
42
28
|
- !ruby/object:Gem::Dependency
|
|
43
|
-
name:
|
|
29
|
+
name: sassc-embedded
|
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
|
45
31
|
requirements:
|
|
46
32
|
- - "~>"
|
|
47
33
|
- !ruby/object:Gem::Version
|
|
48
|
-
version:
|
|
49
|
-
type: :
|
|
34
|
+
version: 1.80.1
|
|
35
|
+
type: :runtime
|
|
50
36
|
prerelease: false
|
|
51
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
38
|
requirements:
|
|
53
39
|
- - "~>"
|
|
54
40
|
- !ruby/object:Gem::Version
|
|
55
|
-
version:
|
|
41
|
+
version: 1.80.1
|
|
56
42
|
- !ruby/object:Gem::Dependency
|
|
57
|
-
name:
|
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
|
59
|
-
requirements:
|
|
60
|
-
- - ">="
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0'
|
|
63
|
-
type: :development
|
|
64
|
-
prerelease: false
|
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- - ">="
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0'
|
|
70
|
-
- !ruby/object:Gem::Dependency
|
|
71
|
-
name: dartsass-ruby
|
|
43
|
+
name: sprockets
|
|
72
44
|
requirement: !ruby/object:Gem::Requirement
|
|
73
45
|
requirements:
|
|
74
|
-
- - "
|
|
46
|
+
- - ">"
|
|
75
47
|
- !ruby/object:Gem::Version
|
|
76
48
|
version: '3.0'
|
|
77
49
|
type: :runtime
|
|
78
50
|
prerelease: false
|
|
79
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
52
|
requirements:
|
|
81
|
-
- - "
|
|
53
|
+
- - ">"
|
|
82
54
|
- !ruby/object:Gem::Version
|
|
83
55
|
version: '3.0'
|
|
84
56
|
- !ruby/object:Gem::Dependency
|
|
85
|
-
name:
|
|
57
|
+
name: sprockets-rails
|
|
86
58
|
requirement: !ruby/object:Gem::Requirement
|
|
87
59
|
requirements:
|
|
88
60
|
- - ">="
|
|
@@ -96,35 +68,7 @@ dependencies:
|
|
|
96
68
|
- !ruby/object:Gem::Version
|
|
97
69
|
version: '0'
|
|
98
70
|
- !ruby/object:Gem::Dependency
|
|
99
|
-
name:
|
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
|
101
|
-
requirements:
|
|
102
|
-
- - ">="
|
|
103
|
-
- !ruby/object:Gem::Version
|
|
104
|
-
version: 4.0.0
|
|
105
|
-
type: :runtime
|
|
106
|
-
prerelease: false
|
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
-
requirements:
|
|
109
|
-
- - ">="
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: 4.0.0
|
|
112
|
-
- !ruby/object:Gem::Dependency
|
|
113
|
-
name: sprockets
|
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
|
115
|
-
requirements:
|
|
116
|
-
- - ">"
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: '3.0'
|
|
119
|
-
type: :runtime
|
|
120
|
-
prerelease: false
|
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
-
requirements:
|
|
123
|
-
- - ">"
|
|
124
|
-
- !ruby/object:Gem::Version
|
|
125
|
-
version: '3.0'
|
|
126
|
-
- !ruby/object:Gem::Dependency
|
|
127
|
-
name: sprockets-rails
|
|
71
|
+
name: tilt
|
|
128
72
|
requirement: !ruby/object:Gem::Requirement
|
|
129
73
|
requirements:
|
|
130
74
|
- - ">="
|
|
@@ -159,10 +103,11 @@ files:
|
|
|
159
103
|
- lib/sassc/rails/railtie.rb
|
|
160
104
|
- lib/sassc/rails/template.rb
|
|
161
105
|
- lib/sassc/rails/version.rb
|
|
162
|
-
homepage: https://github.com/
|
|
106
|
+
homepage: https://github.com/tablecheck/dartsass-sprockets
|
|
163
107
|
licenses:
|
|
164
108
|
- MIT
|
|
165
|
-
metadata:
|
|
109
|
+
metadata:
|
|
110
|
+
rubygems_mfa_required: 'true'
|
|
166
111
|
post_install_message:
|
|
167
112
|
rdoc_options: []
|
|
168
113
|
require_paths:
|
|
@@ -171,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
171
116
|
requirements:
|
|
172
117
|
- - ">="
|
|
173
118
|
- !ruby/object:Gem::Version
|
|
174
|
-
version:
|
|
119
|
+
version: '3.1'
|
|
175
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
121
|
requirements:
|
|
177
122
|
- - ">="
|
|
178
123
|
- !ruby/object:Gem::Version
|
|
179
124
|
version: '0'
|
|
180
125
|
requirements: []
|
|
181
|
-
rubygems_version: 3.
|
|
126
|
+
rubygems_version: 3.5.11
|
|
182
127
|
signing_key:
|
|
183
128
|
specification_version: 4
|
|
184
129
|
summary: Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.
|