Skip to content

Commit

Permalink
Fixing generator webpacker issues (decidim#8427)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu committed Oct 26, 2021
1 parent 0b93792 commit af0889b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ def component(component_name)
template "circleci/config.yml", "#{component_folder}/.circleci/config.yml"

app_folder = "#{component_folder}/app"
template "app/assets/config/component_manifest.js", "#{app_folder}/assets/config/decidim_#{component_name}_manifest.js"
template "app/assets/images/decidim/component/icon.svg", "#{app_folder}/assets/images/decidim/#{component_name}/icon.svg"
template "app/packs/js/entrypoint.js", "#{app_folder}/packs/entrypoints/decidim_#{component_name}.js"
template "app/packs/images/decidim/component/icon.svg", "#{app_folder}/packs/images/decidim/#{component_name}/icon.svg"
template "app/packs/stylesheets/decidim/default.scss", "#{app_folder}/packs/stylesheets/decidim/#{component_name}/#{component_name}.scss"
template "app/controllers/decidim/component/application_controller.rb.erb", "#{app_folder}/controllers/decidim/#{component_name}/application_controller.rb"
template "app/controllers/decidim/component/admin/application_controller.rb.erb", "#{app_folder}/controllers/decidim/#{component_name}/admin/application_controller.rb"
template "app/helpers/decidim/component/application_helper.rb.erb", "#{app_folder}/helpers/decidim/#{component_name}/application_helper.rb"
Expand All @@ -47,6 +48,7 @@ def component(component_name)
chmod "#{bin_folder}/rails", "+x"

config_folder = "#{component_folder}/config"
template "config/assets.rb.erb", "#{config_folder}/assets.rb"
template "config/locales/en.yml.erb", "#{config_folder}/locales/en.yml"
template "config/i18n-tasks.yml.erb", "#{config_folder}/i18n-tasks.yml"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Images
require.context("../images", true)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* css for decidim_<%= component_name %> */
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

base_path = File.expand_path("..", __dir__)

Decidim::Webpacker.register_path("#{base_path}/app/packs")
Decidim::Webpacker.register_entrypoints(
decidim_<%= component_name %>: "#{base_path}/app/packs/entrypoints/decidim_<%= component_name %>.js"
)
Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/<%= component_name %>/<%= component_name %>")

0 comments on commit af0889b

Please sign in to comment.