react-native-electron-platform 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -2
- package/src/modules/windowManager.js +4 -3
- package/webpack.config.mjs +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-electron-platform",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "A boilerplate and utilities for running React Native applications in Electron",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -30,8 +30,17 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"webpack": "^5.0.0",
|
|
33
|
+
"webpack-cli": "^5.0.0",
|
|
34
|
+
"webpack-dev-server": "^4.0.0",
|
|
33
35
|
"html-webpack-plugin": "^5.0.0",
|
|
34
|
-
"webpack-
|
|
36
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.0",
|
|
37
|
+
"@babel/core": "^7.0.0",
|
|
38
|
+
"@babel/preset-env": "^7.0.0",
|
|
39
|
+
"@babel/preset-react": "^7.0.0",
|
|
40
|
+
"@babel/preset-typescript": "^7.0.0",
|
|
41
|
+
"babel-loader": "^9.0.0",
|
|
42
|
+
"react-refresh": "^0.14.0",
|
|
43
|
+
"file-loader": "^6.0.0"
|
|
35
44
|
},
|
|
36
45
|
"peerDependencies": {
|
|
37
46
|
"react-native": ">=0.60.0"
|
|
@@ -2,6 +2,7 @@ import { BrowserWindow, screen, session } from "electron";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import { app, dialog } from "electron";
|
|
5
|
+
import { ApiUrl } from "react-native-electron-platform/webpack.config.mjs";
|
|
5
6
|
|
|
6
7
|
export function createMainWindow(__dirname) {
|
|
7
8
|
const primaryDisplay = screen.getPrimaryDisplay();
|
|
@@ -23,7 +24,7 @@ export function createMainWindow(__dirname) {
|
|
|
23
24
|
nodeIntegration: false,
|
|
24
25
|
contextIsolation: true,
|
|
25
26
|
sandbox: false,
|
|
26
|
-
webSecurity:
|
|
27
|
+
webSecurity: true,
|
|
27
28
|
disableBlinkFeatures: "AutoLoadIconsForPage",
|
|
28
29
|
nativeWindowOpen: true,
|
|
29
30
|
spellcheck: true,
|
|
@@ -90,8 +91,8 @@ function loadAppContent(mainWindow, __dirname) {
|
|
|
90
91
|
const isDev = isDevMode();
|
|
91
92
|
|
|
92
93
|
if (isDev) {
|
|
93
|
-
mainWindow.loadURL(
|
|
94
|
-
console.log("DEV MODE:
|
|
94
|
+
mainWindow.loadURL(ApiUrl);
|
|
95
|
+
console.log("DEV MODE:", ApiUrl);
|
|
95
96
|
} else {
|
|
96
97
|
const possiblePaths = [
|
|
97
98
|
path.join(__dirname, "web-build/index.html"),
|
package/webpack.config.mjs
CHANGED
|
@@ -8,6 +8,9 @@ import packageJson from '../../package.json' with { type: 'json' };
|
|
|
8
8
|
import { generateAlias, generateFallback } from './src/webpackConfigHelper.mjs';
|
|
9
9
|
|
|
10
10
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const port = process.env.PORT || 5001;
|
|
12
|
+
const host = process.env.HOST || 'localhost';
|
|
13
|
+
export const ApiUrl = `http://${host}:${port}`;
|
|
11
14
|
|
|
12
15
|
// Plugin to copy vector icon fonts
|
|
13
16
|
class CopyFontsPlugin {
|
|
@@ -20,6 +23,12 @@ class CopyFontsPlugin {
|
|
|
20
23
|
fs.mkdirSync(destDir, { recursive: true });
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
// Add fallback check for missing source directory
|
|
27
|
+
if (!fs.existsSync(sourceDir)) {
|
|
28
|
+
console.warn(`[CopyFontsPlugin] Warning: Fonts directory not found at ${sourceDir}. Skipping font copy.`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
const files = fs.readdirSync(sourceDir);
|
|
24
33
|
files.forEach(file => {
|
|
25
34
|
const source = path.join(sourceDir, file);
|
|
@@ -36,8 +45,8 @@ export default {
|
|
|
36
45
|
devtool: 'source-map',
|
|
37
46
|
|
|
38
47
|
devServer: {
|
|
39
|
-
port:
|
|
40
|
-
host:
|
|
48
|
+
port: port,
|
|
49
|
+
host: host,
|
|
41
50
|
hot: true,
|
|
42
51
|
compress: true,
|
|
43
52
|
historyApiFallback: true,
|