Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
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 // Reap zombie HMR WebSocket connections that linger after refresh.
40 // Without this, dead sockets exhaust the browser's per-origin connection
41 // pool and the dev server stops responding.
42 config.devServer.onListening = devServer => {
43 devServer.server.on('connection', socket => {
44 socket.setTimeout(10000)
45 socket.on('timeout', () => socket.destroy())
46 })
47 }
48 } else {
49 // Support static CDN for chunks
50 config.output.publicPath = 'auto'
51 }
52
53 if (GENERATE_STATS || OPEN_ANALYZER) {
54 config.plugins.push(
55 new BundleAnalyzerPlugin({
56 openAnalyzer: OPEN_ANALYZER,
57 generateStatsFile: true,
58 statsFilename: '../stats.json',
59 analyzerMode: OPEN_ANALYZER ? 'server' : 'json',
60 defaultSizes: 'parsed',
61 }),
62 )
63 }
64 if (process.env.SENTRY_AUTH_TOKEN) {
65 config.plugins.push(
66 sentryWebpackPlugin({
67 org: 'blueskyweb',
68 project: 'app',
69 authToken: process.env.SENTRY_AUTH_TOKEN,
70 release: {
71 // fallback needed for Render.com deployments
72 name: process.env.SENTRY_RELEASE || version,
73 dist: process.env.SENTRY_DIST,
74 },
75 }),
76 )
77 }
78 return config
79}