Skip to content

Commit

Permalink
* Fix Babel configuration for Electron main process to support ES mod…
Browse files Browse the repository at this point in the history
…ules.

* Fix filter for webpack entries for renderer process.
  • Loading branch information
hpneo committed Feb 12, 2021
1 parent e71347c commit bc4f04a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 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.2)
webpacker-electron (0.1.3)
rails (>= 6.0.0)
webpacker

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

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

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

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

const electronConfig = {
target: "electron-renderer",
Expand Down
8 changes: 7 additions & 1 deletion lib/install/lib/javascript/babel.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
const path = require("path");
const { config } = require("@rails/webpacker");

require("@babel/register")({
extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".ts", ".tsx"],
cwd: path.join(__dirname, "../.."),
overrides: [
{
test: "./src/packs/electron",
test: path.resolve(
"./",
config.source_path,
config.source_entry_path,
"electron",
),
presets: [
[
"@babel/preset-env",
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.2'
VERSION = '0.1.3'
end
end

0 comments on commit bc4f04a

Please sign in to comment.