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 })
31 config.module.rules = [
32 ...(config.module.rules || []),
33 reactNativeWebWebviewConfiguration,
34 ]
35 if (env.mode === 'development') {
36 config.plugins.push(new ReactRefreshWebpackPlugin())
37 } else {
38 // Support static CDN for chunks
39 config.output.publicPath = 'auto'
40 }
41
42 if (GENERATE_STATS || OPEN_ANALYZER) {
43 config.plugins.push(
44 new BundleAnalyzerPlugin({
45 openAnalyzer: OPEN_ANALYZER,
46 generateStatsFile: true,
47 statsFilename: '../stats.json',
48 analyzerMode: OPEN_ANALYZER ? 'server' : 'json',
49 defaultSizes: 'parsed',
50 }),
51 )
52 }
53 if (process.env.SENTRY_AUTH_TOKEN) {
54 config.plugins.push(
55 sentryWebpackPlugin({
56 org: 'blueskyweb',
57 project: 'app',
58 authToken: process.env.SENTRY_AUTH_TOKEN,
59 release: {
60 // fallback needed for Render.com deployments
61 name: process.env.SENTRY_RELEASE || version,
62 dist: process.env.SENTRY_DIST,
63 },
64 }),
65 )
66 }
67 return config
68}