forked from e-mission/e-mission-phone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
86 lines (85 loc) · 3.01 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
const path = require('path')
const webpack = require('webpack')
module.exports = {
entry: './www/index.js',
output: {
path: path.resolve(__dirname, 'www/dist'),
filename: 'bundle.js',
},
module: {
rules: [
// to load CSS and SCSS (enketo-core only supplies SCSS)
{
test: /\.(scss|css)$/,
include: [path.resolve(__dirname, 'www/css'),
path.resolve(__dirname, 'www/manual_lib'),
path.resolve(__dirname, 'node_modules/enketo-core'),
path.resolve(__dirname, 'node_modules/leaflet')],
use: ['style-loader', 'css-loader', 'sass-loader'],
},
// to resolve url() in CSS
{
test: /\.(png|jpg)$/,
include: [path.resolve(__dirname, 'www/css'),
path.resolve(__dirname, 'node_modules/react-native-paper'),
path.resolve(__dirname, 'node_modules/@react-navigation/elements')],
use: 'url-loader',
},
// necessary for react-native-web to bundle JSX
{
test: /\.(js|jsx|ts|tsx)$/,
include: [path.resolve(__dirname, 'www'),
path.resolve(__dirname, 'node_modules/react-native-vector-icons')],
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
},
},
// necessary to load TypeScript files
{
test: /\.(ts|tsx)?$/,
include: path.resolve(__dirname, 'www'),
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
// necessary for react-native-paper to load images, fonts, and vector graphics
{
test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/,
include: [path.resolve(__dirname, 'www'),
path.resolve(__dirname, 'resources'),
path.resolve(__dirname, 'node_modules/react-native-vector-icons')],
type: 'asset/resource',
},
],
},
plugins: [
// to load jQuery and moment globally
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
moment: 'moment',
L: 'leaflet',
}),
new webpack.DefinePlugin({
// __DEV__ is needed by FlashList; it's set false for production so that certain debugging
// checks can be skipped and performance can be improved
__DEV__: process.env.NODE_ENV !== 'production' || true,
}),
],
// "react-native" must be aliased to "react-native-web"
// https://necolas.github.io/react-native-web/docs/setup/#package-aliasing
resolve: {
alias: {
'react-native$': 'react-native-web',
'react-native-webview': 'react-native-web-webview',
/* Enketo expects its per-app configuration to be available as 'enketo-config',
so we have to alias it here.
https://github.com/enketo/enketo-core#global-configuration */
'enketo/config': path.resolve(__dirname, 'www/js/config/enketo-config')
},
extensions: ['.web.js', '.jsx', '.tsx', '.ts', '.js'],
},
}