Skip to content

Commit f17518d

Browse files
authored
Merge pull request #15 from fschwahn/configurable-build-options
Make build_options configurable
2 parents e03702b + 49f4883 commit f17518d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The `dartsass:build` is automatically attached to `assets:precompile`, so before
2525
By default, only `app/assets/stylesheets/application.scss` will be built. If you'd like to change the path of this stylesheet, add additional entry points, or customize the name of the built file, use the `Rails.application.config.dartsass.builds` configuration hash.
2626

2727

28-
```
28+
```ruby
2929
# config/initializers/dartsass.rb
3030
Rails.application.config.dartsass.builds = {
3131
"app/index.sass" => "app.css",
@@ -35,6 +35,15 @@ Rails.application.config.dartsass.builds = {
3535

3636
The hash key is the relative path to a Sass file in `app/assets/stylesheets/` and the hash value will be the name of the file output to `app/assets/builds/`.
3737

38+
## Configuring build options
39+
40+
By default, sass is invoked with `--style=compressed --no-source-map`. You can adjust these options by overwriting `Rails.application.config.dartsass.build_options`.
41+
42+
```ruby
43+
# config/initializers/dartsass.rb
44+
Rails.application.config.dartsass.build_options << " --quiet-deps"
45+
```
46+
3847
## Importing assets from gems
3948
`dartsass:build` includes application [assets paths](https://guides.rubyonrails.org/asset_pipeline.html#search-paths) as Sass [load paths](https://sass-lang.com/documentation/at-rules/use#load-paths). Assuming the gem has made assets visible to the Rails application, no additional configuration is required to use them.
4049

lib/dartsass/engine.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ module Dartsass
44
class Engine < ::Rails::Engine
55
config.dartsass = ActiveSupport::OrderedOptions.new
66
config.dartsass.builds = { "application.scss" => "application.css" }
7+
config.dartsass.build_options = "--style=compressed --no-source-map"
78
end
89
end

lib/tasks/build.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def dartsass_build_mapping
99
end
1010

1111
def dartsass_build_options
12-
"--style=compressed --no-source-map"
12+
Rails.application.config.dartsass.build_options
1313
end
1414

1515
def dartsass_load_paths

0 commit comments

Comments
 (0)