Skip to content

Commit

Permalink
Improve installer template and fix webpack configuration for main pro…
Browse files Browse the repository at this point in the history
…cess in production environment
  • Loading branch information
hpneo committed Feb 19, 2021
1 parent bc4f04a commit a71a506
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 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.3)
webpacker-electron (0.1.4)
rails (>= 6.0.0)
webpacker

Expand Down
6 changes: 5 additions & 1 deletion lib/install/config/webpack/electron/main/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const path = require("path");
const { config } = require("@rails/webpacker");
const environment = require("../../environment");

environment.entry.delete("application");
Object.keys(environment.entry)
.filter((key) => !key.startsWith("electron"))
.forEach((entry) => {
environment.entry.delete(entry);
});

const electronConfig = {
target: "electron-main",
Expand Down
12 changes: 6 additions & 6 deletions lib/install/lib/javascript/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ require("@babel/register")({
cwd: path.join(__dirname, "../.."),
overrides: [
{
test: path.resolve(
"./",
config.source_path,
config.source_entry_path,
"electron",
),
presets: [
[
"@babel/preset-env",
Expand All @@ -24,6 +18,12 @@ require("@babel/register")({
},
],
],
plugins: [
[
"module-resolver",
{ root: [path.join(__dirname, "../..", config.source_path)] },
],
],
},
],
});
10 changes: 6 additions & 4 deletions lib/install/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
append_to_file Rails.root.join(".gitignore") do
<<~TEXT
# Electron
public/packs-electron
public/dist
/public/packs-electron
/public/dist
!/public/assets
TEXT
end
Expand All @@ -61,8 +63,8 @@

say "Installing all Electron dependencies"

run "yarn add --dev electron electron-builder electron-notarize electron-devtools-installer @babel/register dotenv dotenv-webpack [email protected] concurrently cross-env yaml"
run "yarn add electron-updater electron-log electron-debug"
run "yarn add --dev electron-builder electron-notarize @babel/register babel-plugin-module-resolver dotenv dotenv-webpack [email protected] concurrently cross-env yaml"
run "yarn add electron electron-devtools-installer electron-updater electron-log electron-debug"
run "yarn run electron-builder install-app-deps"

say "Webpacker now supports Electron 🎉", :green
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.3'
VERSION = '0.1.4'
end
end

0 comments on commit a71a506

Please sign in to comment.