-
-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathwebpack.config.cjs
57 lines (53 loc) · 1.56 KB
/
webpack.config.cjs
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
const commonConfig = require('common/webpack.config.cjs')
const { merge } = require('webpack-merge')
const { join, resolve } = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const mode = process.env.NODE_ENV?.trim() || 'development'
const alias = {
'@/modules/ipc.js': join(__dirname, 'src', 'ipc.js'),
'@/modules/support.js': join(__dirname, 'src', 'support.js')
}
/** @type {import('webpack').Configuration} */
const capacitorConfig = {
devtool: 'source-map',
entry: [join(__dirname, 'src', 'main.js')],
output: {
path: join(__dirname, 'build', 'nodejs'),
filename: 'index.js'
},
mode,
externals: {
'utp-native': 'require("utp-native")',
bridge: 'require("bridge")'
},
resolve: {
aliasFields: [],
mainFields: ['module', 'main', 'node'],
alias: {
...alias,
wrtc: false,
'node-datachannel': false,
'bittorrent-tracker/lib/client/http-tracker.js': resolve('../node_modules/bittorrent-tracker/lib/client/http-tracker.js'),
'webrtc-polyfill': false // no webrtc on mobile, need the resources
}
},
target: 'node',
devServer: {
devMiddleware: {
writeToDisk: true
},
hot: true,
client: {
overlay: { errors: true, warnings: false, runtimeErrors: false }
},
port: 5001
},
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: join(__dirname, 'public', 'nodejs') }
]
})
]
}
module.exports = [capacitorConfig, merge(commonConfig(__dirname, alias, 'browser', 'index'), { entry: [join(__dirname, 'src', 'capacitor.js')] })]