-
Notifications
You must be signed in to change notification settings - Fork 320
/
webpack.dev.config.js
91 lines (79 loc) · 2.71 KB
/
webpack.dev.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
// The dev webpack config exports configs to build developer bundles:
// 1. default - okta-sign-in.js - full widget for developers. Supports both OIE and Classic engines.
// 2. classic - okta-sign-in.classic.js - classic widget for developers. Does not support OIE (idx) engine.
// 3. oie - okta-sign-in.oie.js - oie widget for developers. Does not support Classic (authn) engine
var common = require('./webpack.common.config');
var plugins = require('./scripts/buildtools/webpack/plugins');
var usePolyfill = require('./scripts/buildtools/webpack/polyfill');
var path = require('path');
var PLAYGROUND = path.resolve(__dirname, 'playground');
var ASSETS_DIR = path.resolve(__dirname, 'assets');
var DEFAULT_ENTRIES = {
'default': {
entry: './src/exports/cdn/default.ts',
},
'classic': {
entry: './src/exports/cdn/classic.ts',
engine: 'classic'
},
'oie': {
entry: './src/exports/cdn/oie.ts',
engine: 'oie'
},
'polyfill': {
entry: './polyfill/index.js',
outputLibrary: null
},
'css': {
entry: `${ASSETS_DIR}/sass/okta-sign-in.scss`,
copyAssets: true,
},
'debugger': {
entry: './src/plugins/OktaPluginDebugger/index.ts',
outputLibrary: null
},
};
module.exports = (env = {}) => {
const { isProduction, skipAnalyzer } = env;
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],
...(process.env.ENTRY !== 'css' && { css: DEFAULT_ENTRIES.css })
};
}
const configs = Object.keys(entries).map(entryName => {
const entryValue = entries[entryName];
const fileNameBase = entryName === 'default' ? 'okta-sign-in' : `okta-sign-in.${entryName}`;
const webpackConfig = {
...common({
...(entryName !== 'css' && { outputFilename: `${fileNameBase}.js` }),
...entryValue,
}),
plugins: plugins({
isProduction,
skipAnalyzer,
analyzerFile: `${fileNameBase}.analyzer`,
copyAssets: entryValue.copyAssets,
})
};
if (isProduction) {
// development bundle does not include runtime transforms
usePolyfill(webpackConfig);
} else {
webpackConfig.optimization.minimize = false;
if (process.env.IE11_COMPAT_MODE === 'true' && entryName === 'default') {
usePolyfill(webpackConfig);
}
}
if (env.mockDuo) {
console.log('======> Mocking Duo iFrame'); // eslint-disable-line no-console
Object.assign(webpackConfig.resolve.alias, {
'@okta/duo': `${PLAYGROUND}/mocks/spec-duo/duo-mock.js`,
});
}
return webpackConfig;
});
return configs;
};