mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1const createExpoWebpackConfigAsync = require('@expo/webpack-config')
2const {withAlias} = require('@expo/webpack-config/addons')
3const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
4const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
5
6const GENERATE_STATS = process.env.EXPO_PUBLIC_GENERATE_STATS === '1'
7const OPEN_ANALYZER = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1'
8
9const reactNativeWebWebviewConfiguration = {
10 test: /postMock.html$/,
11 use: {
12 loader: 'file-loader',
13 options: {
14 name: '[name].[ext]',
15 },
16 },
17}
18
19module.exports = async function (env, argv) {
20 let config = await createExpoWebpackConfigAsync(env, argv)
21 config = withAlias(config, {
22 'react-native$': 'react-native-web',
23 'react-native-webview': 'react-native-web-webview',
24 })
25 config.module.rules = [
26 ...(config.module.rules || []),
27 reactNativeWebWebviewConfiguration,
28 ]
29 if (env.mode === 'development') {
30 config.plugins.push(new ReactRefreshWebpackPlugin())
31 } else {
32 // Support static CDN for chunks
33 config.output.publicPath = 'auto'
34 }
35
36 if (GENERATE_STATS || OPEN_ANALYZER) {
37 config.plugins.push(
38 new BundleAnalyzerPlugin({
39 openAnalyzer: OPEN_ANALYZER,
40 generateStatsFile: true,
41 statsFilename: '../stats.json',
42 analyzerMode: OPEN_ANALYZER ? 'server' : 'json',
43 defaultSizes: 'parsed',
44 }),
45 )
46 }
47 return config
48}