WARNING: This is proof of concept code! For example: Everything is an evil module function. Not well designed.
Can a Ruby application bundle and/or use two versions of a Sass library?
Based on this Neat GitHub Issue the proposal was to allow a special import to target a library and version. Like this:
@import 'neat@2.0';
.test { @include grid-container; }
Based on this import, the application would render using Neat v2.0.0 vs the bundled 1.8.0.
- Bundling multiple gems of the same name in a single app is not a thing.
- Leverage the SassPaths gem to setup
Sass.load_paths
. - Then use
SassPaths.with_replacements
in v2.0 to swap load paths before rendering a Sass template. - Implemented a primitive template scanner for Sass dependency detection/replacements.
- Created a simple
neat@2.0.scss
to delegate to whateverneat
is inSass.load_paths
.
Please see the neato_test.rb file for the tests and browse the lib directory for details.
There are so many ways a Ruby application could install additional dependences. For example, bundler/inline is a good choice in some cases. Others might be to use Yarn alongside your application - and there may be others.
require 'bundler/inline'
gemfile true, ui: Bundler::UI::Silent.new do
gem 'neat', '2.0.0'
end
Using Bundler's inline would require a script as it posses issues inside a running application. I think Yarn might be a good choice alongside a Ruby or Rails application.
The Neato::Sass
would use SassC if installed. However I have not yet setup an Appraisal yet to test it. Should be fine though, I use SassC all the time this way.