Hey!
Actually, the method above caused two major issues:
- the js / css files were not working properly for some reason (strange encoding bugs) on Android
- and it is not working at all on a Distribution app on iOS! (everything is sandboxed)
We ended up copying the files during the prebuild phase of expo with a custom expo plugin.
const { withXcodeProject, withDangerousMod } = require('@expo/config-plugins')
const path = require('path')
const fs = require('fs')
const BITMOVIN_ASSET_SOURCE_PATH = '../src/modules/player/uiConfig/assets'
const BITMOVIN_JS_ASSET_NAME = 'player-ui.bmjs'
const BITMOVIN_CSS_ASSET_NAME = 'player-ui-css.bmcss'
const BITMOVIN_JS_BUNDLED_FILENAME = 'bitmovinplayer-ui.js'
const BITMOVIN_CSS_BUNDLED_FILENAME = 'bitmovinplayer-ui.css'
const withBitmovinUIResources = (config) => {
// iOS configuration
config = withXcodeProject(config, (xcodeProjectConfig) => {
const projectRoot = xcodeProjectConfig.modRequest.projectRoot
const iosProjectRoot = path.join(projectRoot, 'ios')
const sourcePath = path.join(projectRoot, BITMOVIN_ASSET_SOURCE_PATH)
const jsSource = path.join(sourcePath, BITMOVIN_JS_ASSET_NAME)
const cssSource = path.join(sourcePath, BITMOVIN_CSS_ASSET_NAME)
// Destination files in iOS project
const jsDestination = path.join(iosProjectRoot, BITMOVIN_JS_BUNDLED_FILENAME)
const cssDestination = path.join(iosProjectRoot, BITMOVIN_CSS_BUNDLED_FILENAME)
validateSourceFilesExist(jsSource, cssSource)
// Copy files with correct extensions
fs.copyFileSync(jsSource, jsDestination)
fs.copyFileSync(cssSource, cssDestination)
// Add to app bundle as resources
const xcodeProject = xcodeProjectConfig.modResults
xcodeProject.addResourceFile(BITMOVIN_JS_BUNDLED_FILENAME)
xcodeProject.addResourceFile(BITMOVIN_CSS_BUNDLED_FILENAME)
return xcodeProjectConfig
})
// Android configuration
config = withDangerousMod(config, [
'android',
(androidConfig) => {
const projectRoot = androidConfig.modRequest.projectRoot
const androidAssetsDir = path.join(
androidConfig.modRequest.platformProjectRoot,
'app/src/main/assets',
)
const sourcePath = path.join(projectRoot, BITMOVIN_ASSET_SOURCE_PATH)
const jsSource = path.join(sourcePath, BITMOVIN_JS_ASSET_NAME)
const cssSource = path.join(sourcePath, BITMOVIN_CSS_ASSET_NAME)
const jsDestination = path.join(androidAssetsDir, BITMOVIN_JS_BUNDLED_FILENAME)
const cssDestination = path.join(androidAssetsDir, BITMOVIN_CSS_BUNDLED_FILENAME)
validateSourceFilesExist(jsSource, cssSource)
if (!fs.existsSync(androidAssetsDir)) {
fs.mkdirSync(androidAssetsDir, { recursive: true })
}
fs.copyFileSync(jsSource, jsDestination)
fs.copyFileSync(cssSource, cssDestination)
return androidConfig
},
])
return config
}
const validateSourceFilesExist = (jsSource, cssSource) => {
if (!fs.existsSync(jsSource)) {
throw new Error(`Bitmovin UI JS source file ${jsSource} does not exist`)
}
if (!fs.existsSync(cssSource)) {
throw new Error(`Bitmovin UI CSS source file ${cssSource} does not exist`)
}
}
module.exports = withBitmovinUIResources
In the metro config
config.resolver.assetExts = [...config.resolver.assetExts, 'bmjs', 'bmcss']
And in your Expo app config
// ...
plugins: [
'./plugins/withBitmovinUIResources',
],
// ...
This worked fine for us. Biggest problem is that we need a native deployment (instead of eas update) for every change 