forked from bitfocus/companion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
105 lines (97 loc) · 2.37 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
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
const path = require('path')
const fs = require('fs')
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin')
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN
const distPath = path.resolve(__dirname, 'dist')
const buildFile = fs.readFileSync(path.join(__dirname, 'BUILD')).toString().trim()
module.exports = {
entry: {
main: './main.js',
// Handler: './lib/Surface/USB/Handler.js',
RenderThread: './lib/Graphics/Thread.js',
},
mode: 'production',
devtool: sentryAuthToken ? 'source-map' : undefined,
output: {
// filename: 'main.js',
path: distPath,
},
context: path.resolve(__dirname, '.'),
target: 'node',
// node: {
// __dirname: true,
// __filename: true,
// global: false,
// },
// resolve: {
// fallback: {
// // use native node modules
// fs: false,
// buffer: false,
// path: false,
// stream: false,
// zlib: false,
// timers: false,
// http: false,
// https: false,
// },
// },
externalsPresets: { node: true },
externals: {
// Native libs that are needed
usb: 'commonjs2 usb',
bufferutil: 'commonjs2 bufferutil',
'utf-8-validate': 'commonjs2 utf-8-validate',
'@serialport/bindings-cpp': 'commonjs2 @serialport/bindings-cpp',
'@julusian/skia-canvas': 'commonjs2 @julusian/skia-canvas',
},
experiments: {
topLevelAwait: true,
},
module: {
rules: [
// {
// test: /\.json/,
// type: 'asset/inline',
// },
{
test: /BUILD$/,
type: 'asset/resource',
generator: {
filename: 'BUILD',
},
},
{
test: /SENTRY$/,
type: 'asset/resource',
generator: {
filename: 'SENTRY',
},
},
],
},
plugins: [
sentryAuthToken
? sentryWebpackPlugin({
url: 'https://sentry.bitfocus.io/',
authToken: sentryAuthToken,
org: 'bitfocus',
project: 'companion',
// sourcemaps: {
// assets: [path.join(distPath, '**')],
// deleteFilesAfterUpload: [path.join(distPath, '**/*.map')],
// },
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and needs the `project:releases` and `org:read` scopes
release: {
name: `companion@${buildFile}`,
// HACK: use the legacy method for now, as bitfocus sentry is too old to support the new way
uploadLegacySourcemaps: {
paths: [distPath],
urlPrefix: '~/',
},
},
})
: '',
].filter(Boolean),
}