-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to add extra load paths #7
Conversation
e1ef099
to
c570e03
Compare
Would be lovely to merge this change. We have our assets in some non-standard (and in multiple Engines) folders. |
@@ -36,6 +36,12 @@ Rails.application.config.dartsass.builds = { | |||
|
|||
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/`. | |||
|
|||
By default, only files under `app/assets/stylesheets` will be watched. If you'd like to add extra directories, use the `Rails.application.config.dartsass.extra_load_paths` configuration array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DHH was suggesting all vendor/assets/stylesheets
folders should also be default, is there a way to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems a better approach #11
@@ -4,5 +4,6 @@ module Dartsass | |||
class Engine < ::Rails::Engine | |||
config.dartsass = ActiveSupport::OrderedOptions.new | |||
config.dartsass.builds = { "application.scss" => "application.css" } | |||
config.dartsass.extra_load_paths = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also load all stylesheets by default
config.dartsass.paths = []
def default_paths
Rails.application.config.assets[:paths].select do |path|
path.to_s.match?(/stylesheets/)
end
end
def load_paths
use_paths = config.dartsass.paths || default_paths
[CSS_LOAD_PATH].concat(use_paths).map { |path| "--load-path #{path}" }.join(" ") }
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think is a better approach and doesn't require extra configuration #11
Closed in favour of #11 |
This change allows to add extra load paths to the sass executable.
It is helpful when the an app has cutomized the entry points as well as when the entry points references other files that reside outside of the default
CSS_LOAD_PATH
.That way, when files are changed under those extra directories,
dartsass:watch
will trigger a rebuild.