-
Notifications
You must be signed in to change notification settings - Fork 257
/
webpack.config.js
65 lines (55 loc) · 1.72 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
/*
* This config builds a minified version that can be imported
* anywhere without any dependencies. It also preserves license comments.
*/
var path = require('path');
var webpack = require('webpack');
var fs = require('fs');
var _ = require('lodash');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
var commonConfig = require('./webpack.common.config');
var license = fs.readFileSync('lib/license-header.txt', 'utf8');
var entries = {
'default': './lib/exports/default.ts',
'core': './lib/exports/core.ts',
'authn': './lib/exports/authn.ts',
'idx': './lib/exports/idx.ts',
'myaccount': './lib/exports/myaccount.ts'
};
// if ENTRY env var is passed, filter the entries to include only the named ENTRY
if (process.env.ENTRY) {
entries = {
[process.env.ENTRY]: entries[process.env.ENTRY]
};
}
module.exports = Object.keys(entries).map(function(entryName) {
var plugins = commonConfig.plugins.concat([
// Add a single Okta license after removing others
new webpack.BannerPlugin(license),
]);
// if ANALZYE env var is passed, output analyzer html
if (process.env.ANALYZE) {
plugins.unshift(
new BundleAnalyzerPlugin({
openAnalyzer: false,
reportFilename: `${entryName}.umd.analyzer.html`,
analyzerMode: 'static',
defaultSizes: 'stat'
})
);
}
return _.extend({}, _.cloneDeep(commonConfig), {
mode: (process.env.NODE_ENV === 'development') ? 'development' : 'production',
entry: {
[entryName]: entries[entryName]
},
output: {
path: path.join(__dirname, 'build', 'umd'),
filename: '[name].js',
library: 'OktaAuth',
libraryTarget: 'umd'
},
plugins,
devtool: 'source-map'
});
});