-
Notifications
You must be signed in to change notification settings - Fork 139
/
webpack.config.js
89 lines (76 loc) · 2.11 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
const path = require('path')
const webpack = require('webpack')
const glob = require('glob')
const pkg = require('./package.json')
function newConfig() {
return {
mode: 'development',
optimization: { nodeEnv: false },
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' },
{ test: /\.tsx?$/, loader: 'tslint-loader', enforce: 'pre' },
{ test: /\.js$/, loader: 'source-map-loader', enforce: 'pre' },
// Disable AMD.
{
test: require.resolve('error-stack-parser'),
use: 'imports-loader?define=>false'
},
{
test: require.resolve('stackframe'),
use: 'imports-loader?define=>false'
}
]
},
externals: {
'isomorphic-fetch': 'fetch',
os: {
commonjs: 'os',
commonjs2: 'os'
},
process: 'process'
},
devtool: 'nosources-source-map',
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
libraryTarget: 'umd',
// https://github.com/webpack/webpack/issues/6525
globalObject: "typeof self !== 'undefined' ? self : this"
},
node: {
process: false
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(pkg.version)
}),
new webpack.BannerPlugin({ banner: 'airbrake-js v' + pkg.version })
]
}
}
var client = newConfig()
var clientFiles = ['./src/internal/compat.ts', './src/client.ts']
client.entry = {
client: clientFiles
}
client.output.library = ['airbrakeJs', 'Client']
var clientMin = Object.assign({}, client)
clientMin.mode = 'production'
clientMin.entry = {
'client.min': clientFiles
}
var express = newConfig()
express.entry = {
'instrumentation/express': './src/instrumentation/express.ts'
}
express.output.library = ['airbrakeJs', 'instrumentation', 'express']
var hapi = newConfig()
hapi.entry = {
'instrumentation/hapi': './src/instrumentation/hapi.ts'
}
express.output.library = ['airbrakeJs', 'instrumentation', 'hapi']
module.exports = [client, clientMin, express, hapi]