Skip to content

Commit

Permalink
Fixes #25308 - Additional support for plugins with React
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Prazak authored and Tomas Strachota committed Oct 26, 2018
1 parent 0c08b71 commit 11165fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/helpers/reactjs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def webpacked_plugins_js_for(*plugin_names)
js_tags_for(select_requested_plugins(plugin_names)).join.html_safe
end

def webpacked_plugins_css_for(*plugin_names)
css_tags_for(select_requested_plugins(plugin_names)).join.html_safe
end

def select_requested_plugins(plugin_names)
available_plugins = Foreman::Plugin.with_webpack.map(&:id)
missing_plugins = plugin_names - available_plugins
Expand All @@ -24,4 +28,10 @@ def js_tags_for(requested_plugins)
javascript_include_tag(*webpack_asset_paths(plugin.to_s, :extension => 'js'), "data-turbolinks-track" => true)
end
end

def css_tags_for(requested_plugins)
requested_plugins.map do |plugin|
stylesheet_link_tag(*webpack_asset_paths(plugin.to_s, :extension => 'css'), "data-turbolinks-track" => true)
end
end
end
1 change: 1 addition & 0 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module.exports = env => {
paths: true,
collections: true,
flattening: true,
shorthands: true
}),
// must match config.webpack.manifest_filename
new StatsWriterPlugin({
Expand Down

0 comments on commit 11165fa

Please sign in to comment.