forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
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')
5const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')
6const {version} = require('./package.json')
7
8const GENERATE_STATS = process.env.EXPO_PUBLIC_GENERATE_STATS === '1'
9const OPEN_ANALYZER = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1'
10
11const reactNativeWebWebviewConfiguration = {
12 test: /postMock.html$/,
13 use: {
14 loader: 'file-loader',
15 options: {
16 name: '[name].[ext]',
17 },
18 },
19}
20
21module.exports = async function (env, argv) {
22 let config = await createExpoWebpackConfigAsync(env, argv)
23 config = withAlias(config, {
24 'react-native$': 'react-native-web',
25 'react-native-webview': 'react-native-web-webview',
26 // Force ESM version
27 'unicode-segmenter/grapheme': require
28 .resolve('unicode-segmenter/grapheme')
29 .replace(/\.cjs$/, '.js'),
30 'react-native-gesture-handler': false, // RNGH should not be used on web, so let's cause a build error if it sneaks in
31 '@sentry-internal/replay': false, // not used, ~300kb of dead weight
32 })
33 config.module.rules = [
34 ...(config.module.rules || []),
35 reactNativeWebWebviewConfiguration,
36 ]
37 if (env.mode === 'development') {
38 config.plugins.push(new ReactRefreshWebpackPlugin())
39 } else {
40 // Support static CDN for chunks
41 config.output.publicPath = 'auto'
42 }
43
44 if (GENERATE_STATS || OPEN_ANALYZER) {
45 config.plugins.push(
46 new BundleAnalyzerPlugin({
47 openAnalyzer: OPEN_ANALYZER,
48 generateStatsFile: true,
49 statsFilename: '../stats.json',
50 analyzerMode: OPEN_ANALYZER ? 'server' : 'json',
51 defaultSizes: 'parsed',
52 }),
53 )
54 }
55 if (process.env.SENTRY_AUTH_TOKEN) {
56 config.plugins.push(
57 sentryWebpackPlugin({
58 org: 'blueskyweb',
59 project: 'app',
60 authToken: process.env.SENTRY_AUTH_TOKEN,
61 release: {
62 // fallback needed for Render.com deployments
63 name: process.env.SENTRY_RELEASE || version,
64 dist: process.env.SENTRY_DIST,
65 },
66 }),
67 )
68 }
69 return config
70}