Skip to content

Commit

Permalink
Fix install template to properly inject custom configuration to confi…
Browse files Browse the repository at this point in the history
…g/webpack/environment.js
  • Loading branch information
hpneo committed Feb 12, 2021
1 parent bf07950 commit e71347c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
webpacker-electron (0.1.1)
webpacker-electron (0.1.2)
rails (>= 6.0.0)
webpacker

Expand Down
3 changes: 2 additions & 1 deletion lib/install/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
say "Updating webpack environment configuration to ignore Electron packs"

unless File.read(Rails.root.join("config/webpack/environment.js")).include?(".filter((key) => key.match(/^electron/))")
insert_into_file Rails.root.join("config/webpack/environment.js"), after: "const { environment } = require(\"@rails/webpacker\");\n" do
insert_into_file Rails.root.join("config/webpack/environment.js"), after: /const\ \{\ environment\ \}\ =\ require\(['"]@rails\/webpacker['"]\)/ do
<<~JS
Object.keys(environment.entry)
.filter((key) => key.match(/^electron/))
.forEach((entry) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/webpacker.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace :webpacker do
source_entry_path = Webpacker.config.source_entry_path.join("electron")

Dir.chdir(Rails.root) do
Kernel.exec "yarn run cross-env NODE_ENV=development electron -r ./lib/javascript/babel #{source_entry_path.join('main.js')}"
Kernel.exec "yarn run cross-env NODE_ENV=development electron -r ./lib/javascript/babel.js #{source_entry_path.join('main.js')}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/webpacker/electron/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Webpacker
module Electron
VERSION = '0.1.1'
VERSION = '0.1.2'
end
end

0 comments on commit e71347c

Please sign in to comment.