Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ Would output the following in your view:
### Assets
You can require all the components CSS and JS automatically by requiring `mountain_view` in your main JS and CSS files.

If you do not want to have rails compile the assets so you can handle them with another method such as Webpacker
you can skip the asset configuration by setting `skip_assets` eg:

```ruby
#config/initializers/mountain_view.rb

MountainView.configure do |config|
config.skip_assets = true
end


### Global Stylesheets
In case you want to add global stylesheets (e.g. reset, bootstrap, a grid system, etc) to your Mountain View components you can do it by calling them with an initializer

Expand Down
1 change: 1 addition & 0 deletions lib/mountain_view/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Configuration
attr_accessor :included_stylesheets
attr_accessor :styleguide_path
attr_accessor :extra_pages
attr_accessor :skip_assets
attr_reader :components_path

def initialize
Expand Down
10 changes: 6 additions & 4 deletions lib/mountain_view/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ class Engine < ::Rails::Engine
end

initializer "mountain_view.assets" do |_app|
Rails.application.config.assets.paths <<
MountainView.configuration.components_path
Rails.application.config.assets.precompile +=
%w[mountain_view/styleguide.css mountain_view/styleguide.js]
unless MountainView.configuration.skip_assets
Rails.application.config.assets.paths <<
MountainView.configuration.components_path
Rails.application.config.assets.precompile +=
%w[mountain_view/styleguide.css mountain_view/styleguide.js]
end
end

initializer "mountain_view.append_view_paths" do |_app|
Expand Down
7 changes: 7 additions & 0 deletions test/mountain_view/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ class MountainViewConfigurationTest < ActiveSupport::TestCase

assert_equal config.styleguide_path, "style-guide"
end

test "set skip_assets option" do
config = MountainView::Configuration.new
config.skip_assets = true

assert config.skip_assets
end
end