forked from okta/okta-auth-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.cdn.config.js
51 lines (44 loc) · 1.39 KB
/
webpack.cdn.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
/*
* 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');
var commonConfig = require('./webpack.common.config');
var license = fs.readFileSync('lib/license-header.txt', 'utf8');
var baseConfig = _.cloneDeep(commonConfig);
var extraBabelPlugins = [
['@babel/plugin-transform-modules-commonjs', {
'strict': true,
'noInterop': false
}],
'add-module-exports' // converts export.default into module.exports
];
function addBabelPlugins(rule) {
if (rule.use) {
rule.use.forEach(addBabelPlugins);
return;
}
if (rule.loader === 'babel-loader' && rule.options) {
rule.options = _.cloneDeep(rule.options);
rule.options.plugins = rule.options.plugins.concat(extraBabelPlugins);
}
}
baseConfig.module.rules.forEach(addBabelPlugins);
module.exports = _.extend({}, baseConfig, {
mode: 'production',
entry: './lib/OktaAuth', // only export OktaAuth constructor
output: {
path: path.join(__dirname, 'build', 'dist'),
filename: 'okta-auth-js.min.js',
library: 'OktaAuth',
libraryTarget: 'var'
},
plugins: commonConfig.plugins.concat([
// Add a single Okta license after removing others
new webpack.BannerPlugin(license)
]),
devtool: 'source-map'
});