This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
webpack.config.js
58 lines (57 loc) · 1.57 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
// webpack considers .web.ts and .ts to be different extensions
// We use both for web vs node implementations of some clients.
const moduleFileExtensions = ['js', 'web.ts', 'ts']
module.exports = {
target: 'web',
mode: 'production',
entry: './src/index.ts',
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/typescript', '@babel/preset-env'],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
],
},
},
},
],
},
resolve: {
extensions: moduleFileExtensions.map((ext) => `.${ext}`),
// Some libraries import Node modules but don't use them in the browser.
// Tell webpack to provide empty mocks for them so importing them works.
fallback: {
module: false,
dns: 'mock',
fs: false,
http2: false,
net: false,
tls: false,
child_process: false,
// Webpack no longer auto-polyfills for node core modules.
// These are the polyfills for the necessary modules.
assert: 'assert',
buffer: 'buffer',
crypto: 'crypto-browserify',
os: 'os-browserify/browser',
stream: 'stream-browserify',
url: 'url',
util: 'util',
zlib: 'browserify-zlib',
},
},
output: {
filename: 'index.js',
library: 'XpringJS',
libraryTarget: 'umd',
globalObject: "(typeof self !== 'undefined' ? self : this)",
},
}