-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathwebpack.config.js
More file actions
39 lines (31 loc) · 1.18 KB
/
Copy pathwebpack.config.js
File metadata and controls
39 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const path = require('path');
const fs = require('fs');
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const { resolver } = require('./metro.config');
const root = path.resolve(__dirname, '..');
const node_modules = path.join(__dirname, 'node_modules');
const packages = path.resolve(__dirname, '..', 'packages');
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
config.module.rules.push({
test: /\.(js|jsx|ts|tsx)$/,
include: path.resolve(root, 'src'),
use: 'babel-loader',
});
// We need to make sure that only one version is loaded for peerDependencies
// So we alias them to the versions in example's node_modules
Object.assign(config.resolve.alias, {
...resolver.extraNodeModules,
'react-native-web': path.join(node_modules, 'react-native-web'),
});
fs.readdirSync(packages)
.filter((name) => !name.startsWith('.'))
.forEach((name) => {
const pak = require(`../packages/${name}/package.json`);
if (pak.source == null) {
return;
}
config.resolve.alias[pak.name] = path.resolve(packages, name, pak.source);
});
return config;
};