react-native-electron-platform 0.0.2 → 0.0.3
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 +3 -1
- package/webpack.config.mjs +159 -0
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.3",
|
|
4
4
|
"description": "A boilerplate and utilities for running React Native applications in Electron",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"node": ">=14.0.0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
|
+
"index.mjs",
|
|
45
|
+
"webpack.config.mjs",
|
|
44
46
|
"src/",
|
|
45
47
|
"README.md",
|
|
46
48
|
"LICENSE"
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import packageJson from '../../package.json' with { type: 'json' };
|
|
7
|
+
import { generateAlias, generateFallback } from './src/webpackConfigHelper.mjs';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
// Plugin to copy vector icon fonts
|
|
12
|
+
class CopyFontsPlugin {
|
|
13
|
+
apply(compiler) {
|
|
14
|
+
compiler.hooks.afterEmit.tap('CopyFontsPlugin', () => {
|
|
15
|
+
const sourceDir = path.join(__dirname, '../../node_modules/react-native-vector-icons/Fonts');
|
|
16
|
+
const destDir = path.join(__dirname, '../../web-build/fonts');
|
|
17
|
+
|
|
18
|
+
if (!fs.existsSync(destDir)) {
|
|
19
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const files = fs.readdirSync(sourceDir);
|
|
23
|
+
files.forEach(file => {
|
|
24
|
+
const source = path.join(sourceDir, file);
|
|
25
|
+
const dest = path.join(destDir, file);
|
|
26
|
+
fs.copyFileSync(source, dest);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
mode: 'development',
|
|
34
|
+
entry: path.resolve(__dirname, '../../electron/index.js'),
|
|
35
|
+
devtool: 'source-map',
|
|
36
|
+
|
|
37
|
+
devServer: {
|
|
38
|
+
port: 5001,
|
|
39
|
+
host: 'localhost',
|
|
40
|
+
hot: true,
|
|
41
|
+
compress: true,
|
|
42
|
+
historyApiFallback: true,
|
|
43
|
+
liveReload: true,
|
|
44
|
+
static: {
|
|
45
|
+
directory: path.join(__dirname, '../../web-build'),
|
|
46
|
+
publicPath: '/',
|
|
47
|
+
},
|
|
48
|
+
client: {
|
|
49
|
+
overlay: {
|
|
50
|
+
errors: true,
|
|
51
|
+
warnings: false,
|
|
52
|
+
},
|
|
53
|
+
reconnect: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
resolve: {
|
|
58
|
+
extensions: ['.web.js', '.web.ts', '.web.tsx', '.js', '.jsx', '.ts', '.tsx', '.json'],
|
|
59
|
+
mainFields: ['browser', 'module', 'main'],
|
|
60
|
+
fullySpecified: false,
|
|
61
|
+
alias: generateAlias(),
|
|
62
|
+
fallback: generateFallback(),
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
module: {
|
|
66
|
+
rules: [
|
|
67
|
+
// Your source files
|
|
68
|
+
{
|
|
69
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
70
|
+
exclude: /node_modules\/(?!react-native-electron-platform)/,
|
|
71
|
+
use: {
|
|
72
|
+
loader: 'babel-loader',
|
|
73
|
+
options: {
|
|
74
|
+
presets: [
|
|
75
|
+
'@babel/preset-env',
|
|
76
|
+
'@babel/preset-react',
|
|
77
|
+
'@babel/preset-typescript',
|
|
78
|
+
],
|
|
79
|
+
plugins: [
|
|
80
|
+
['@babel/plugin-transform-class-properties', { loose: true }],
|
|
81
|
+
['@babel/plugin-transform-private-methods', { loose: true }],
|
|
82
|
+
['@babel/plugin-transform-private-property-in-object', { loose: true }],
|
|
83
|
+
'@babel/plugin-transform-runtime',
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
// node_modules packages that contain JSX
|
|
90
|
+
{
|
|
91
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
92
|
+
include: /node_modules.*(@react-navigation|react-native|@react-native|react-native-vector-icons)/,
|
|
93
|
+
use: {
|
|
94
|
+
loader: 'babel-loader',
|
|
95
|
+
options: {
|
|
96
|
+
presets: [
|
|
97
|
+
'@babel/preset-env',
|
|
98
|
+
'@babel/preset-react',
|
|
99
|
+
'@babel/preset-typescript',
|
|
100
|
+
],
|
|
101
|
+
plugins: [
|
|
102
|
+
['@babel/plugin-transform-class-properties', { loose: true }],
|
|
103
|
+
['@babel/plugin-transform-private-methods', { loose: true }],
|
|
104
|
+
['@babel/plugin-transform-private-property-in-object', { loose: true }],
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// Assets
|
|
111
|
+
{ test: /\.(png|jpg|gif|svg)$/, type: 'asset/resource' },
|
|
112
|
+
|
|
113
|
+
// Font files for react-native-vector-icons
|
|
114
|
+
{
|
|
115
|
+
test: /\.(ttf|otf)$/,
|
|
116
|
+
use: [
|
|
117
|
+
{
|
|
118
|
+
loader: 'file-loader',
|
|
119
|
+
options: {
|
|
120
|
+
name: '[name].[ext]',
|
|
121
|
+
outputPath: 'fonts/',
|
|
122
|
+
publicPath: '/fonts/',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
include: /node_modules\/react-native-vector-icons/,
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// General font files
|
|
130
|
+
{ test: /\.(woff|woff2|eot)$/, type: 'asset/resource' },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
output: {
|
|
135
|
+
filename: 'bundle.js',
|
|
136
|
+
path: path.resolve(__dirname, '../../web-build'),
|
|
137
|
+
clean: true,
|
|
138
|
+
libraryTarget: 'umd', // UMD fixes 'exports is not defined'
|
|
139
|
+
globalObject: 'this',
|
|
140
|
+
assetModuleFilename: 'fonts/[name].[ext]',
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
plugins: [
|
|
144
|
+
new CopyFontsPlugin(),
|
|
145
|
+
new HtmlWebpackPlugin({
|
|
146
|
+
template: path.resolve(__dirname, 'src/index.html'),
|
|
147
|
+
inject: false,
|
|
148
|
+
templateParameters: {
|
|
149
|
+
title: packageJson.name,
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
|
|
154
|
+
performance: {
|
|
155
|
+
hints: 'warning',
|
|
156
|
+
maxEntrypointSize: 512000,
|
|
157
|
+
maxAssetSize: 512000,
|
|
158
|
+
},
|
|
159
|
+
};
|