2023-03-13 16:01:43 -05:00
|
|
|
const createExpoWebpackConfigAsync = require('@expo/webpack-config')
|
|
|
|
const {withAlias} = require('@expo/webpack-config/addons')
|
2023-09-05 19:13:42 +01:00
|
|
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
2024-04-03 19:31:29 -07:00
|
|
|
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
|
2025-03-14 12:08:19 -05:00
|
|
|
const {sentryWebpackPlugin} = require('@sentry/webpack-plugin')
|
|
|
|
const {version} = require('./package.json')
|
2024-04-03 19:31:29 -07:00
|
|
|
|
|
|
|
const GENERATE_STATS = process.env.EXPO_PUBLIC_GENERATE_STATS === '1'
|
|
|
|
const OPEN_ANALYZER = process.env.EXPO_PUBLIC_OPEN_ANALYZER === '1'
|
2023-03-13 16:01:43 -05:00
|
|
|
|
|
|
|
const reactNativeWebWebviewConfiguration = {
|
|
|
|
test: /postMock.html$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = async function (env, argv) {
|
|
|
|
let config = await createExpoWebpackConfigAsync(env, argv)
|
|
|
|
config = withAlias(config, {
|
|
|
|
'react-native$': 'react-native-web',
|
|
|
|
'react-native-webview': 'react-native-web-webview',
|
|
|
|
})
|
|
|
|
config.module.rules = [
|
|
|
|
...(config.module.rules || []),
|
|
|
|
reactNativeWebWebviewConfiguration,
|
|
|
|
]
|
2023-09-05 19:13:42 +01:00
|
|
|
if (env.mode === 'development') {
|
|
|
|
config.plugins.push(new ReactRefreshWebpackPlugin())
|
2025-01-15 13:35:00 -06:00
|
|
|
} else {
|
|
|
|
// Support static CDN for chunks
|
|
|
|
config.output.publicPath = 'auto'
|
2023-09-05 19:13:42 +01:00
|
|
|
}
|
2024-04-03 19:31:29 -07:00
|
|
|
|
|
|
|
if (GENERATE_STATS || OPEN_ANALYZER) {
|
|
|
|
config.plugins.push(
|
|
|
|
new BundleAnalyzerPlugin({
|
|
|
|
openAnalyzer: OPEN_ANALYZER,
|
|
|
|
generateStatsFile: true,
|
|
|
|
statsFilename: '../stats.json',
|
|
|
|
analyzerMode: OPEN_ANALYZER ? 'server' : 'json',
|
|
|
|
defaultSizes: 'parsed',
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
}
|
2025-03-14 12:08:19 -05:00
|
|
|
if (process.env.SENTRY_AUTH_TOKEN) {
|
|
|
|
config.plugins.push(
|
|
|
|
sentryWebpackPlugin({
|
|
|
|
org: 'blueskyweb',
|
|
|
|
project: 'app',
|
|
|
|
authToken: process.env.SENTRY_AUTH_TOKEN,
|
|
|
|
release: {
|
|
|
|
// env is undefined for Render.com builds, fall back
|
|
|
|
name: process.env.SENTRY_RELEASE || version,
|
|
|
|
dist: process.env.SENTRY_DIST,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
}
|
2023-03-13 16:01:43 -05:00
|
|
|
return config
|
|
|
|
}
|