Integration with webpacker / Rails 5.1
Hi there,
are you planning on improving the compatibility of mountain_view with webpacker / Rails 5.1?
For instance, I'd like to load my components SCSS and JS as a pack, instead of assets, so I can use ES6 in my component's javascript.
For now, I've managed to do that by naming my component JS file something else than {component}.js (so mountain_view does not load it) and then manually importing it in my javascript pack.
Are you open to this?
Thanks!
@Spone this is a great idea.
We're definitively open to make MoutainView compatible with with webpacker! And open to any feedback on how to do it, if you already have some experience with it. I personally haven't integrated webpacker and mountain view yet.
Also, this may be slighlty related to #55
I've managed to setup webpack and mountain_view in the same app. Actually, I'm now using frontend/components as my default components directory.
With the lines bellow I was able to load components at /styleguide.
# config/initializers/mountain_view.rb
MountainView.configure do |c|
c.components_path = Rails.root.join('frontend', 'components')
end
# config/application.rb
config.eager_load_paths += Dir[Rails.root.join('frontend', 'components', '{*}')]
I'm also autoloading/importing components with
export default function loadComponents(context) {
context.keys().forEach(context);
}
// Load components
loadComponents(require.context("../components", true, /\.js$/));
There may be problems or adjustments with this setup (I'm not currently using autogenerated styleguide) but it is working pretty well.