forked from okta/okta-auth-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.cdn.config.js
38 lines (35 loc) · 1.22 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
/*
* 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 babelOptions = _.find(baseConfig.module.rules, (rule) => rule.loader === 'babel-loader').options;
var extraBabelPlugins = [
['@babel/plugin-transform-modules-commonjs', {
'strict': true,
'noInterop': false
}],
'add-module-exports' // converts export.default into module.exports
];
babelOptions.plugins = babelOptions.plugins.concat(extraBabelPlugins);
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'
});