dartsass-sprockets 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -13
- data/lib/sassc/rails/compressor.rb +1 -10
- 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 -5
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
@@ -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`. 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
|
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://github.com/sass/sass/blob/40c50cb/js-api-doc/deprecations.d.ts#L260
|
@@ -16,16 +16,7 @@ module Sprockets
|
|
16
16
|
end
|
17
17
|
|
18
18
|
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
|
19
|
+
SassC::Engine.new(args[0][:data], { style: :compressed }).render
|
26
20
|
end
|
27
|
-
|
28
|
-
# sprockets 2.x
|
29
|
-
alias evaluate call
|
30
21
|
end
|
31
22
|
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,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,7 +9,7 @@ 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
15
|
name: railties
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 1.80.1
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 1.80.1
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sprockets
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.5.
|
126
|
+
rubygems_version: 3.5.11
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.
|