-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
136 lines (132 loc) · 3.62 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const path = require("path");
const webpack = require("webpack");
// eslint-disable-next-line @typescript-eslint/naming-convention, import/no-extraneous-dependencies
const TerserPlugin = require("terser-webpack-plugin");
const compilationOpts = {
/* eslint-disable @typescript-eslint/naming-convention */
WEB: !!process.env.MCEWEB,
WEBREPORT: !!process.env.MCEWEBREPORT,
ONDEVICE: !!process.env.MCEMOBILE,
ANDROID: !!process.env.MCEMOBILEANDROID,
IOS: !!process.env.MCEMOBILEIOS,
"ifdef-verbose": true,
/* eslint-enable @typescript-eslint/naming-convention */
};
const mainEntryPoint = "./lib/App.tsx";
module.exports = (env, argv) => {
return {
entry: mainEntryPoint,
output: {
filename: "bundle.js",
chunkFilename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
library: "mce",
libraryTarget: "umd",
},
devtool: process.env.MCEDEBUG ? "source-map" : false,
externals: ["socket.io", "windows-pac-resolver", "proxy-agent", "fs", "net", "tls", { child_process: "child_process" }],
resolve: {
extensions: [".mjs", ".js", ".jsx", ".ts", ".tsx", ".json"],
alias: {
stream: require.resolve("stream-browserify/"),
},
fallback: {
path: require.resolve("path-browserify"),
crypto: require.resolve("crypto-browserify"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify/browser"),
util: require.resolve("util/"),
stream: require.resolve("stream-browserify"),
zlib: require.resolve("browserify-zlib"),
assert: require.resolve("assert/"),
constants: require.resolve("constants-browserify"),
timers: require.resolve("timers-browserify"),
buffer: require.resolve("buffer"),
process: require.resolve("process"),
// eslint-disable-next-line @typescript-eslint/naming-convention
_stream_transform: false,
},
},
plugins: [
// fix "process is not defined" error:
// (do "npm install process" before running the build)
new webpack.ProvidePlugin({
process: "process/browser",
// eslint-disable-next-line @typescript-eslint/naming-convention
Buffer: ["buffer", "Buffer"],
}),
],
stats: "errors-only",
module: {
rules: [
{
test: /\.(ts)x?$/,
use: [
{
loader: "ts-loader",
options: {
logLevel: "info",
logInfoToStdOut: true,
},
},
],
},
{
test: /\.m?js$/,
include: /node_modules/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
},
{
test: /\.css$/,
use: [{
loader: "style-loader",
options: {
insertInto: "body",
},
},
{
loader: "css-loader",
options: {
modules: {
localIdentName: "[path][name]__[local]--[hash:base64:5]",
},
},
},
],
},
{
test: /\.(otf|eot|svg|ttf|woff|woff2)$/,
use: {
loader: "file-loader",
options: {
name: "fonts/[name].[ext]",
},
},
},
{
test: /opencv.js$/,
use: [
{
loader: "file-loader",
options: {
name: "dtlScripts/[name].[ext]",
},
},
],
},
{
test: /\.(png|jpg|gif|gltf)$/,
use: {
loader: "file-loader",
options: {
name: "[folder]/[name].[ext]",
},
},
},
]},
};
};