-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.web.ts
76 lines (74 loc) · 2.05 KB
/
webpack.config.web.ts
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const isDev = process.argv.indexOf('-p') === -1;
module.exports = {
entry: {
entry: './index.web.ts'
},
output: {
path: path.join(process.cwd(), './dist-H5'),
filename: 'bundle.js'
},
devServer: {
historyApiFallback: {
index: './index.html'
}
},
module: {
rules: [{
test: /\.(gif|jpe?g|png|svg)$/,
use: {
loader: 'file-loader'
}
},
{
test: /\.(js|jsx|ts|tsx)$/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: false,
presets: [
'module:metro-react-native-babel-preset',
'@babel/preset-typescript'
],
plugins: [
'@babel/plugin-transform-runtime'
]
}
}
],
exclude: /node_modules/
}]
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(process.cwd(), './index.html'),
filename: 'index.html',
inject: 'body',
minify: {
removeComments: !isDev,
collapseWhitespace: !isDev,
minifyJS: !isDev,
minifyCSS: !isDev
},
title: 'React Native H5',
favicon: path.join(process.cwd(), './android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png')
})
],
resolve: {
extensions: [
'.web.ts',
'.web.tsx',
'.ts',
'.tsx',
'.js',
'.jsx'
],
alias: {
'react-native$': 'react-native-web'
}
},
mode: isDev ? 'development' : 'production',
devtool: isDev ? 'cheap-module-eval-source-map' : undefined
};