-
Notifications
You must be signed in to change notification settings - Fork 261
/
webpack.config.js
85 lines (81 loc) · 2.31 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
const { exec } = require('child_process')
const path = require('path')
const { ESBuildMinifyPlugin } = require('esbuild-loader')
const webpack = require('webpack')
// Run `yarn start.plugins` to enable debug mode.
// This mode will serve the plugin bundle via a local dev-server.
const debug = process.env.WEBPACK_SERVE
// Try exposing our socket to adb (errors are fine):
if (process.env.WEBPACK_SERVE) {
console.log('adb reverse tcp:8101 tcp:8101')
exec('adb reverse tcp:8101 tcp:8101', () => {})
}
module.exports = {
devtool: debug ? 'source-map' : undefined,
devServer: {
allowedHosts: 'all',
hot: false,
static: false,
port: 8101
},
entry: './src/util/corePluginBundle.js',
mode: debug ? 'development' : 'production',
module: {
rules: [
{
test: /\.js$/,
exclude: /(@babel\/runtime|babel-runtime)/,
use: debug
? {
loader: '@sucrase/webpack-loader',
options: { transforms: [] }
}
: {
loader: 'esbuild-loader',
options: {
target: 'chrome67',
tsconfigRaw: {}
}
}
}
]
},
optimization: {
minimizer: [
new ESBuildMinifyPlugin({
target: 'chrome67'
})
]
},
output: {
filename: 'plugin-bundle.js',
path: path.join(path.resolve(__dirname), 'android/app/src/main/assets/edge-core')
},
performance: { hints: false },
plugins: [
new webpack.IgnorePlugin({ resourceRegExp: /^(https-proxy-agent)$/ }),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
new webpack.ProvidePlugin({
process: path.resolve('node_modules/process/browser.js')
})
],
resolve: {
aliasFields: ['browser'],
fallback: {
assert: require.resolve('assert'),
crypto: require.resolve('crypto-browserify'),
fs: false,
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
string_decoder: require.resolve('string_decoder'),
url: require.resolve('url'),
vm: require.resolve('vm-browserify')
},
mainFields: ['browser', 'module', 'main']
}
}