dartsass-sprockets 3.1.0 → 3.2.1
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 +65 -14
- data/lib/sassc/rails/compressor.rb +5 -11
- data/lib/sassc/rails/railtie.rb +4 -7
- data/lib/sassc/rails/template.rb +37 -40
- data/lib/sassc/rails/version.rb +1 -1
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2da8ac4585dc1219da7fa83a1a51f76b7a68545ca9971664887d72baf80782
|
4
|
+
data.tar.gz: 25e69df6f4a1bdc15318297c2b087047b2b33e40793062df7e1eaf88a53bd93f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69494bb5da2bed7d97fb784c475fef625a9b89f5d2246da2d6780f7f9f72ba9cf4caded668e770695c792edf1ab1033fdf0b91c65a7311f22f195162e08a7caf
|
7
|
+
data.tar.gz: e3d1bec2c6a13752fa1c3d0c2c69a01cd4411de624910e077ea22fae5df74dadc9c5f276f8526b50eab9538dec4851fe1a878c2db942e01246aee018e4355c54
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Dart Sass for
|
1
|
+
# Dart Sass for Sprockets
|
2
2
|
|
3
3
|
[](https://github.com/tablecheck/dartsass-sprockets/actions/workflows/build.yml)
|
4
4
|
[](https://rubygems.org/gems/dartsass-sprockets)
|
@@ -33,30 +33,79 @@ The current version of `dartsass-sprockets` supports:
|
|
33
33
|
|
34
34
|
For older versions of Ruby and Rails may be supported with earlier versions of this gem.
|
35
35
|
|
36
|
-
|
36
|
+
## CSS Minification (Production)
|
37
37
|
|
38
|
-
This gem
|
39
|
-
|
38
|
+
This gem uses a Railtie to automatically set the following
|
39
|
+
configuration in all environments *except* Development:
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
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`.
|
44
50
|
|
45
|
-
##
|
51
|
+
## Source Maps (Development)
|
46
52
|
|
47
53
|
To turn on inline source maps, add the following configuration
|
48
|
-
to your `development.rb` file:
|
54
|
+
to your `config/environments/development.rb` file:
|
49
55
|
|
50
56
|
```ruby
|
51
|
-
# config/environments/development.rb
|
57
|
+
# in config/environments/development.rb
|
52
58
|
config.sass.inline_source_maps = true
|
53
59
|
```
|
54
60
|
|
55
|
-
|
56
|
-
(
|
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
|
57
65
|
|
58
|
-
|
59
|
-
|
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`. Overridden by `Rails.config.assets.css_compressor`; see "CSS Minification" above. |
|
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 [Dart Sass deprecations][dartsass-deprecations]. |
|
94
|
+
| `fatal_deprecations`* | `Array<String>` | An array of deprecations to treat as fatal. Refer to [Dart Sass deprecations][dartsass-deprecations]. |
|
95
|
+
| `future_deprecations`* | `Array<String>` | An array of future deprecations to opt-into early. Refer to [Dart Sass 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
|
102
|
+
|
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.
|
60
109
|
|
61
110
|
## Alternatives
|
62
111
|
|
@@ -80,3 +129,5 @@ Note these source maps are *inline* and will be appended to the compiled
|
|
80
129
|
3. Commit your changes (`git commit -am 'Add some feature'`) - try to include tests
|
81
130
|
4. Push to the branch (`git push origin my-new-feature`)
|
82
131
|
5. Create a new Pull Request
|
132
|
+
|
133
|
+
[dartsass-deprecations]: https://sass-lang.com/documentation/js-api/interfaces/deprecations/
|
@@ -12,20 +12,14 @@ module Sprockets
|
|
12
12
|
read_cache: false,
|
13
13
|
style: :compressed
|
14
14
|
}.merge(options).freeze
|
15
|
-
|
15
|
+
|
16
|
+
ver1 = SassC::Rails::VERSION
|
17
|
+
ver2 = SassC::Embedded::VERSION if defined?(SassC::Embedded::VERSION)
|
18
|
+
@cache_key = "#{self.class.name}:#{ver1}:#{ver2}:#{Sprockets::DigestUtils.digest(options)}".freeze
|
16
19
|
end
|
17
20
|
|
18
21
|
def call(*args)
|
19
|
-
|
20
|
-
data # sprockets 2.x
|
21
|
-
else
|
22
|
-
args[0][:data] # sprockets 3.x
|
23
|
-
end
|
24
|
-
|
25
|
-
SassC::Engine.new(input, { style: :compressed }).render
|
22
|
+
SassC::Engine.new(args[0][:data], { style: :compressed }).render
|
26
23
|
end
|
27
|
-
|
28
|
-
# sprockets 2.x
|
29
|
-
alias evaluate call
|
30
24
|
end
|
31
25
|
end
|
data/lib/sassc/rails/railtie.rb
CHANGED
@@ -15,8 +15,8 @@ module SassC
|
|
15
15
|
# Initialize the load paths to an empty array
|
16
16
|
config.sass.load_paths = []
|
17
17
|
|
18
|
-
#
|
19
|
-
config.sass.
|
18
|
+
# Silence deprecation warnings during compilation that come from dependencies
|
19
|
+
config.sass.quiet_deps = false
|
20
20
|
|
21
21
|
# Set the default stylesheet engine
|
22
22
|
# It can be overridden by passing:
|
@@ -72,11 +72,8 @@ module SassC
|
|
72
72
|
end
|
73
73
|
|
74
74
|
initializer :setup_compression, group: :all do |app|
|
75
|
-
|
76
|
-
|
77
|
-
app.config.sass.style ||= :expanded
|
78
|
-
else
|
79
|
-
app.config.assets.css_compressor = :sass unless app.config.assets.key?(:css_compressor)
|
75
|
+
unless ::Rails.env.development?
|
76
|
+
app.config.assets.css_compressor = :sass unless app.config.assets.key?(:css_compressor) # rubocop:disable Style/SoleNestedConditional
|
80
77
|
end
|
81
78
|
end
|
82
79
|
end
|
data/lib/sassc/rails/template.rb
CHANGED
@@ -3,79 +3,76 @@
|
|
3
3
|
require 'sprockets/version'
|
4
4
|
require 'sprockets/sass_processor'
|
5
5
|
require 'sprockets/utils'
|
6
|
+
require 'sprockets/uri_utils'
|
6
7
|
|
7
8
|
module SassC
|
8
9
|
module Rails
|
9
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
|
+
|
10
25
|
def initialize(options = {}, &block) # rubocop:disable Lint/MissingSuper
|
11
26
|
@cache_version = options[:cache_version]
|
12
|
-
@cache_key = "#{self.class.name}:#{VERSION}:#{SassC::VERSION}:#{@cache_version}"
|
13
|
-
|
27
|
+
@cache_key = "#{self.class.name}:#{VERSION}:#{::SassC::VERSION}:#{@cache_version}"
|
28
|
+
@importer_class = options[:importer] || ::SassC::Rails::Importer
|
14
29
|
@sass_config = options[:sass_config] || {}
|
15
30
|
@functions = Module.new do
|
31
|
+
include ::SassC::Script::Functions
|
16
32
|
include Functions
|
17
33
|
include options[:functions] if options[:functions]
|
18
34
|
class_eval(&block) if block_given?
|
19
35
|
end
|
20
36
|
end
|
21
37
|
|
22
|
-
def call(input)
|
38
|
+
def call(input) # rubocop:disable Metrics/AbcSize
|
23
39
|
context = input[:environment].context_class.new(input)
|
24
40
|
|
25
41
|
options = {
|
42
|
+
load_paths: input[:environment].paths | (::Rails.application.config.sass.load_paths || []),
|
26
43
|
filename: input[:filename],
|
27
|
-
line_comments: line_comments?,
|
28
44
|
syntax: self.class.syntax,
|
29
|
-
|
30
|
-
importer:
|
45
|
+
functions: @functions,
|
46
|
+
importer: @importer_class,
|
31
47
|
sprockets: {
|
32
48
|
context: context,
|
33
49
|
environment: input[:environment],
|
34
50
|
dependencies: context.metadata[:dependency_paths]
|
35
51
|
}
|
36
|
-
}
|
37
|
-
|
38
|
-
engine = ::SassC::Engine.new(input[:data], options)
|
52
|
+
}
|
39
53
|
|
40
|
-
|
41
|
-
|
54
|
+
PASS_THRU_OPTIONS.each do |option|
|
55
|
+
options[option] = ::Rails.application.config.sass.send(option)
|
42
56
|
end
|
43
57
|
|
44
|
-
context.metadata.merge(data: css)
|
45
|
-
end
|
46
|
-
|
47
|
-
def config_options
|
48
|
-
opts = { style: sass_style, load_paths: load_paths }
|
49
|
-
|
50
58
|
if ::Rails.application.config.sass.inline_source_maps
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
options.merge!(source_map_file: '.',
|
60
|
+
source_map_embed: true,
|
61
|
+
source_map_contents: true)
|
54
62
|
end
|
55
63
|
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def sass_style
|
60
|
-
(::Rails.application.config.sass.style || :expanded).to_sym
|
61
|
-
end
|
62
|
-
|
63
|
-
def load_paths
|
64
|
-
::Rails.application.config.sass.load_paths || []
|
65
|
-
end
|
64
|
+
engine = ::SassC::Engine.new(input[:data], options.compact)
|
66
65
|
|
67
|
-
|
68
|
-
::Rails.application.config.sass.line_comments
|
69
|
-
end
|
66
|
+
css = engine.render
|
70
67
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
else
|
77
|
-
right
|
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])
|
78
73
|
end
|
74
|
+
|
75
|
+
context.metadata.merge(data: css, sass_dependencies: sass_dependencies)
|
79
76
|
end
|
80
77
|
|
81
78
|
# The methods in the Functions module were copied here from sprockets in order to
|
data/lib/sassc/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dartsass-sprockets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Boland
|
8
8
|
- Johnny Shields
|
9
|
-
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2025-04-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
@@ -31,14 +30,14 @@ dependencies:
|
|
31
30
|
requirements:
|
32
31
|
- - "~>"
|
33
32
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
33
|
+
version: 1.80.1
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
38
|
- - "~>"
|
40
39
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
40
|
+
version: 1.80.1
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: sprockets
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +107,6 @@ licenses:
|
|
108
107
|
- MIT
|
109
108
|
metadata:
|
110
109
|
rubygems_mfa_required: 'true'
|
111
|
-
post_install_message:
|
112
110
|
rdoc_options: []
|
113
111
|
require_paths:
|
114
112
|
- lib
|
@@ -123,8 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
121
|
- !ruby/object:Gem::Version
|
124
122
|
version: '0'
|
125
123
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
127
|
-
signing_key:
|
124
|
+
rubygems_version: 3.6.6
|
128
125
|
specification_version: 4
|
129
126
|
summary: Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.
|
130
127
|
test_files: []
|