-
Notifications
You must be signed in to change notification settings - Fork 321
/
webpack.release.config.js
137 lines (119 loc) · 3.92 KB
/
webpack.release.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// The release webpack config exports configs to build CDN bundles:
// 1. default - okta-sign-in.min.js - full widget for endusers. generates a minified built version of the
// widget that includes everything necessary to run (including all vendor
// libraries)
// 2. no polyfill - okta-sign-in.no-polyfill.min.js - full widget for endusers who do not need IE11.
// 3. classic - okta-sign-in.classic.min.js - classic widget for endusers. Does not support OIE. No polyfills.
// 4. oie - okta-sign-in.oie.min.js - oie widget for endusers. Does not support Classic engine. No polyfills.
// 5. polyfill - okta-sign-in.polyfill.min.js - polyfill for embedded widget that need to support IE11 and PKCE
// 6. plugin a11y - okta-plugin-a11y.js - add-on that enhances support for accesibility
// 7. debugger - okta-sign-in.debugger.min.js
var path = require('path');
var config = require('./webpack.common.config');
var plugins = require('./scripts/buildtools/webpack/plugins');
var useRuntime = require('./scripts/buildtools/webpack/runtime');
var usePolyfill = require('./scripts/buildtools/webpack/polyfill');
var TARGET_DIR = path.resolve(__dirname, 'target');
var DEFAULT_ENTRIES = {
// 1. default (default entry, minified, with polyfill)
'default': {
includePolyfill: true,
includeRuntime: true,
entry: './src/exports/cdn/default.ts',
outputFilename: 'okta-sign-in.min.js',
analyzerFile: 'okta-sign-in.min.analyzer'
},
// 2. no polyfill (default entry, minified, no polyfill)
'noPolyfill': {
entry: './src/exports/cdn/default.ts',
outputFilename: 'okta-sign-in.no-polyfill.min.js',
analyzerFile: 'okta-sign-in.no-polyfill.min.analyzer'
},
// 3. classic (classic entry, minified, no polyfill)
'classic': {
entry: './src/exports/cdn/classic.ts',
outputFilename: 'okta-sign-in.classic.min.js',
analyzerFile: 'okta-sign-in.classic.min.analyzer',
engine: 'classic',
},
// 4. oie (oie bundle, minified, no polyfill)
'oie': {
entry: './src/exports/cdn/oie.ts',
outputFilename: 'okta-sign-in.oie.min.js',
analyzerFile: 'okta-sign-in.oie.min.analyzer',
engine: 'oie'
},
// 5. polyfill for IE11 (embedded widgets)
'polyfill': {
entry: './polyfill/index.js',
outputFilename: 'okta-sign-in.polyfill.min.js',
analyzerFile: 'okta-sign-in.polyfill.min.analyzer',
outputLibrary: null
},
// 6. plugins: a11y
'a11y': {
entry: './src/plugins/OktaPluginA11y.ts',
outputFilename: 'okta-plugin-a11y.js',
outputLibrary: 'OktaPluginA11y'
},
// 7. plugins: debugger
'debugger': {
entry: './src/plugins/OktaPluginDebugger/index.ts',
outputFilename: 'okta-sign-in.debugger.min.js',
analyzerFile: 'okta-sign-in.debugger.min.analyzer',
outputLibrary: null,
useBuiltIns: true,
},
'css': {
entry: `${TARGET_DIR}/sass/okta-sign-in.scss`,
copyAssets: true,
},
};
let entries = { ...DEFAULT_ENTRIES };
// if ENTRY env var is passed, filter the entries to include only the named ENTRY
if (process.env.ENTRY) {
entries = {
[process.env.ENTRY]: DEFAULT_ENTRIES[process.env.ENTRY],
};
if (!['css', 'debugger'].includes(process.env.ENTRY)) {
entries = {
...entries,
css: DEFAULT_ENTRIES.css
};
}
}
const configs = Object.keys(entries).map(entryName => {
const entryValue = entries[entryName];
const {
entry,
outputFilename,
analyzerFile,
engine,
outputLibrary,
includePolyfill,
includeRuntime,
copyAssets,
useBuiltIns,
} = entryValue;
const entryConfig = config({
mode: 'production',
entry,
...(entryName !== 'css' && { outputFilename }),
outputLibrary,
engine,
useBuiltIns,
});
entryConfig.plugins = plugins({
isProduction: true,
analyzerFile,
copyAssets,
});
if (includeRuntime) {
useRuntime(entryConfig);
}
if (includePolyfill) {
usePolyfill(entryConfig);
}
return entryConfig;
});
module.exports = configs;