This repository was archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
111 lines (101 loc) · 2.66 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const path = require('path');
const webpack = require('webpack');
const rootDir = path.resolve(__dirname, './');
const srcDir = path.resolve(rootDir, 'src');
const pubDir = path.resolve(rootDir, 'public');
const modulesDir = path.resolve(rootDir, 'node_modules');
const babelLoaderConfiguration = {
test: /\.js$/,
include: [
path.resolve(srcDir),
path.resolve(modulesDir, 'react-native'),
path.resolve(modulesDir, 'react-native-safe-module'),
path.resolve(modulesDir, 'react-native-safe-area-view'),
path.resolve(modulesDir, 'react-native-tab-view'),
path.resolve(modulesDir, 'react-native-paper'),
path.resolve(modulesDir, 'react-native-vector-icons'),
path.resolve(modulesDir, 'react-native-safe-area-view'),
path.resolve(modulesDir, '@expo/samples'),
path.resolve(modulesDir, '@expo/vector-icons'),
path.resolve(modulesDir, 'react-native-platform-touchable')
],
use: {
loader: 'babel-loader',
options: {
babelrc: false,
plugins: [
'expo-web',
'react-native-web',
'transform-decorators-legacy',
[
'transform-runtime',
{ helpers: false, polyfill: false, regenerator: true }
]
],
presets: ['react-native']
}
}
};
const cssLoaderConfiguration = {
test: /\.css$/,
use: ['style-loader', 'css-loader']
};
const imageLoaderConfiguration = {
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]'
}
}
};
const ttfLoaderConfiguration = {
test: /\.ttf$/,
use: [
{
loader: 'file-loader',
options: {
name: './fonts/[hash].[ext]'
}
}
],
include: [
path.resolve(modulesDir, 'react-native-vector-icons')
]
};
module.exports = {
entry: path.resolve(srcDir, 'index.js'),
devtool: 'eval, cheap-module-eval-source-map',
output: {
filename: 'app.bundle.js',
publicPath: '/',
path: path.resolve(pubDir, 'app')
},
module: {
rules: [
babelLoaderConfiguration,
cssLoaderConfiguration,
imageLoaderConfiguration,
ttfLoaderConfiguration
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'development'
),
__DEV__: process.env.NODE_ENV === 'production' || true
})
],
resolve: {
symlinks: false,
extensions: ['.web.js', '.js'],
alias: {
'./assets/images/expo-icon.png': './assets/images/expo-icon@2x.png',
'./assets/images/slack-icon.png': './assets/images/slack-icon@2x.png',
'@expo/vector-icons': 'expo-web',
expo: 'expo-web',
'react-native': 'react-native-web'
}
}
};