-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
72 lines (65 loc) · 1.87 KB
/
webpack.config.js
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const path = require('path');
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const appDirectory = path.resolve(__dirname, './');
const babelLoaderConfiguration = {
test: /\.js$/,
// Add every directory that needs to be compiled by Babel during the build.
include: [
path.resolve(appDirectory, 'src'),
path.resolve(appDirectory, 'App.js'),
path.resolve(appDirectory, 'node_modules'),
],
use: {
loader: 'babel-loader',
options: {
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-function-bind',
],
presets: ['babel-preset-expo', '@babel/preset-env', '@babel/react'],
},
},
};
const ttfLoaderConfiguration = {
test: /\.ttf$/,
loader: 'url-loader', // or directly file-loader
include: [
path.resolve(appDirectory, 'assets/fonts'),
path.resolve(appDirectory, 'node_modules/expo'),
path.resolve(appDirectory, 'node_modules/@expo'),
path.resolve(appDirectory, 'node_modules/react-native-vector-icons'),
path.resolve(appDirectory, 'node_modules/native-base'),
],
};
const imageLoaderConfiguration = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
};
// Expo CLI will await this method so you can optionally return a promise.
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
config.module = Object.assign({}, config.module, {
rules: [
ttfLoaderConfiguration,
babelLoaderConfiguration,
imageLoaderConfiguration,
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
},
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
},
],
});
// Finally return the new config for the CLI to use.
return config;
};