Bluesky app fork with some witchin' additions 馃挮
at viewport 82 lines 2.7 kB view raw
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') 7const path = require('node:path') 8const SpeedMeasurePlugin = require('speed-measure-webpack-plugin') 9const ProgressPlugin = require('progress-webpack-plugin') 10 11const GENERATE_STATS = process.env.EXPO_PUBLIC_GENERATE_STATS === '1' 12const OPEN_ANALYZER = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1' 13const MEASURE_SPEED = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1' 14 15const reactNativeWebWebviewConfiguration = { 16 test: /postMock.html$/, 17 use: { 18 loader: 'file-loader', 19 options: { 20 name: '[name].[ext]', 21 }, 22 }, 23} 24 25module.exports = async function (env, argv) { 26 let config = await createExpoWebpackConfigAsync(env, argv) 27 config = withAlias(config, { 28 'react-native$': 'react-native-web', 29 'react-native-webview': 'react-native-web-webview', 30 // Force ESM version 31 'unicode-segmenter/grapheme': require 32 .resolve('unicode-segmenter/grapheme') 33 .replace(/\.cjs$/, '.js'), 34 'react-native-gesture-handler': false, // RNGH should not be used on web, so let's cause a build error if it sneaks in 35 }) 36 config.module.rules = [ 37 ...(config.module.rules || []), 38 reactNativeWebWebviewConfiguration, 39 ] 40 if (env.mode === 'development') { 41 config.devtool = 'eval' 42 config.cache = { 43 type: 'filesystem', 44 cacheLocation: path.resolve(__dirname, '.build_cache'), 45 } 46 config.plugins.push(new ProgressPlugin(true)); 47 } else { 48 // Support static CDN for chunks 49 config.output.publicPath = '/' 50 } 51 52 if (GENERATE_STATS || OPEN_ANALYZER) { 53 config.plugins.push( 54 new BundleAnalyzerPlugin({ 55 openAnalyzer: OPEN_ANALYZER, 56 generateStatsFile: true, 57 statsFilename: '../stats.json', 58 analyzerMode: OPEN_ANALYZER ? 'server' : 'json', 59 defaultSizes: 'parsed', 60 }), 61 ) 62 } 63 if (process.env.SENTRY_AUTH_TOKEN) { 64 config.plugins.push( 65 sentryWebpackPlugin({ 66 org: 'blueskyweb', 67 project: 'app', 68 authToken: process.env.SENTRY_AUTH_TOKEN, 69 release: { 70 // fallback needed for Render.com deployments 71 name: process.env.SENTRY_RELEASE || version, 72 dist: process.env.SENTRY_DIST, 73 }, 74 }), 75 ) 76 } 77 if (MEASURE_SPEED) { 78 const spm = SpeedMeasurePlugin() 79 return spm.wrap(config) 80 } 81 return config 82}