Skip to content

Commit 292cd48

Browse files
committed
add app assets to load paths
1 parent 3ff15ea commit 292cd48

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Rails.application.config.dartsass.builds = {
3636

3737
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/`.
3838

39+
## Importing assets from gems
40+
`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.
41+
3942

4043
## Version
4144

lib/tasks/build.rake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ CSS_LOAD_PATH = Rails.root.join("app/assets/stylesheets")
33
CSS_BUILD_PATH = Rails.root.join("app/assets/builds")
44

55
def dartsass_build_mapping
6-
Rails.application.config.dartsass.builds.map { |input, output|
6+
Rails.application.config.dartsass.builds.map { |input, output|
77
"#{CSS_LOAD_PATH.join(input)}:#{CSS_BUILD_PATH.join(output)}"
88
}.join(" ")
99
end
1010

1111
def dartsass_build_options
12-
"--load-path #{CSS_LOAD_PATH} --style=compressed --no-source-map"
12+
"#{load_paths} --style=compressed --no-source-map"
13+
end
14+
15+
def load_paths
16+
[CSS_LOAD_PATH].concat(Rails.application.config.assets.paths)
17+
.map { |path| "--load-path #{path}" }
18+
.join(" ")
1319
end
1420

1521
def dartsass_compile_command

0 commit comments

Comments
 (0)