-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-native-web.config.js
103 lines (97 loc) · 2.19 KB
/
react-native-web.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* eslint-disable prefer-named-capture-group */
const path = require('node:path');
const dotenv = require('dotenv');
const { presets, plugins } = require('./babel.config.js');
const { transformPackagesOnRspack } = require('./shares');
dotenv.config('.env');
const babelLoaderConfiguration = {
test: /\.(ts|tsx|js|jsx)$/i,
include: [new RegExp(`(${transformPackagesOnRspack.join('|')})`)],
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets,
plugins,
},
},
};
const jsModuleConfiguration = {
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
};
const imageLoaderConfiguration = {
test: /\.(png|jpe?g|gif)$/i,
type: 'asset',
};
const svgLoaderConfiguration = {
test: /\\\\.svg$/,
use: [
{
loader: '@svgr/webpack',
},
],
};
module.exports = {
devtool: process.env.NODE_ENV === 'development' ? 'eval-source-map' : false,
devServer: {
allowedHosts: 'all',
},
entry: {
app: path.join(__dirname, 'index.web.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.[hash].js',
clean: true,
},
resolve: {
extensions: ['.web.tsx', '.web.ts', '.tsx', '.ts', '.web.js', '.js'],
alias: {
'react-native': 'react-native-web',
'react-native-share': './src/web/react-native-share',
'@/App': './App',
src: './src',
tests: './tests',
},
},
module: {
rules: [
babelLoaderConfiguration,
jsModuleConfiguration,
imageLoaderConfiguration,
svgLoaderConfiguration,
],
},
builtins: {
html: [
{
template: './index.html',
favicon: './static/favicon.ico',
publicPath: '',
minify: true,
},
],
copy: {
patterns: [
'./static/assets/**/*',
'./static/favicon.ico',
'./static/site.webmanifest',
],
},
define: {
__DEV__: JSON.stringify(process.env.NODE_ENV !== 'production'),
WEB_SENTRY_DSN: JSON.stringify(process.env.WEB_SENTRY_DSN) || 'empty',
process: {
env: {},
},
},
},
optimization: {
sideEffects: false,
moduleIds: 'named',
minimize: false,
},
};