forked from elastic/apm-agent-rum-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
67 lines (62 loc) · 1.58 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
var path = require('path')
var agentVersion = require('./package.json').version
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
var baseOptions = {
entry: './src/index.js',
output: {
filename: 'elastic-apm-js-base.umd.js',
path: path.resolve(__dirname, 'dist', 'bundles'),
library: 'elastic-apm-js-base',
libraryTarget: 'umd'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['babel-preset-es2015'].map(require.resolve)
}
},
{
test: /\.js$/,
loader: 'string-replace-loader',
query: {
search: '%%agent-version%%',
replace: agentVersion
}
}
]
}
}
var bundleConfig = {
entry: baseOptions.entry,
output: baseOptions.output,
module: baseOptions.module,
node: false
}
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
var optimizeConfig = {
entry: baseOptions.entry,
output: {
filename: 'elastic-apm-js-base.umd.min.js',
path: baseOptions.output.path
},
module: baseOptions.module,
devtool: 'source-map',
node: false,
plugins: [
new UglifyJSPlugin({
sourceMap: true,
extractComments: true
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: path.resolve(__dirname, 'reports', 'bundle-analyzer.html'),
generateStatsFile: true,
statsFilename: path.resolve(__dirname, 'reports', 'bundle-analyzer.json'),
openAnalyzer: false
})
]
}
module.exports = [bundleConfig, optimizeConfig]