Skip to content

Commit f3da1c6

Browse files
committed
chore: Solved build web error.
1 parent ba56a09 commit f3da1c6

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

exampleExpo/babel.config.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1+
const path = require('path');
2+
const pak = require('../package.json');
3+
const { isProd } = require('./constants');
4+
15
module.exports = function (api) {
26
api.cache(true);
7+
const plugins = [
8+
'react-native-reanimated/plugin',
9+
'inline-dotenv',
10+
'@babel/plugin-syntax-dynamic-import',
11+
];
12+
13+
if (!isProd) {
14+
return {
15+
presets: ['babel-preset-expo'],
16+
plugins,
17+
};
18+
}
319

420
return {
521
presets: ['babel-preset-expo'],
622
plugins: [
7-
'react-native-reanimated/plugin',
8-
'inline-dotenv',
9-
'@babel/plugin-syntax-dynamic-import',
23+
[
24+
'module-resolver',
25+
{
26+
extensions: ['.tsx', '.ts', '.js', '.json'],
27+
alias: {
28+
[pak.name]: path.join(__dirname, '..', pak.main),
29+
},
30+
},
31+
],
32+
...plugins,
1033
],
1134
};
1235
};

exampleExpo/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
isProd: process.env.NODE_ENV === 'production',
3+
};

exampleExpo/webpack.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const path = require('path');
2+
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
3+
const { resolver } = require('./metro.config');
4+
const { isProd } = require('./constants');
5+
6+
const root = path.resolve(__dirname, '..');
7+
const node_modules = path.join(__dirname, 'node_modules');
8+
9+
module.exports = async function (env, argv) {
10+
const config = await createExpoWebpackConfigAsync(env, argv);
11+
12+
if (!isProd) {
13+
return config;
14+
}
15+
16+
config.output.publicPath = '/react-native-reanimated-carousel';
17+
config.module.rules.push({
18+
test: /\.(js|jsx|ts|tsx)$/,
19+
include: path.resolve(root, 'src'),
20+
use: 'babel-loader',
21+
});
22+
23+
// We need to make sure that only one version is loaded for peerDependencies
24+
// So we alias them to the versions in example's node_modules
25+
Object.assign(config.resolve.alias, {
26+
...resolver.extraNodeModules,
27+
'react-native-web': path.join(node_modules, 'react-native-web'),
28+
});
29+
30+
return config;
31+
};

0 commit comments

Comments
 (0)