-
Notifications
You must be signed in to change notification settings - Fork 8
/
webpack.config.js
105 lines (95 loc) · 2.5 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
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
const Path = require('path');
const webpack = require('webpack');
const version = require('./package.json').version;
const versionDir = `dist/v${version}`;
const majorVersion = version.split('.')[0];
const majorVersionDir = `dist/v${majorVersion}`;
const browserFilename = 'streaming-client.browser.js';
const ieFilename = 'streaming-client.browser.ie.js'
module.exports = (env = {}) => {
let babelLoader;
let entry = './dist/npm/module.js';
let filename = browserFilename;
if (env.ie) {
console.log('Building for IE compatibility');
filename = ieFilename;
entry = [
'./node_modules/unorm/lib/unorm.js',
'./node_modules/whatwg-fetch/fetch.js',
'./dist/npm/module.js'
];
babelLoader = {
test: /\.(cjs|mjs|js)$/,
loader: 'babel-loader',
exclude: [
/@babel\//,
/\bcore-js\b/,
/\bwebpack\/buildin\b/
],
options: {
sourceType: 'unambiguous',
plugins: [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }],
['@babel/plugin-proposal-class-properties'],
['@babel/transform-runtime'],
['@babel/plugin-transform-private-methods']
],
presets: [
['@babel/preset-env', {
corejs: { version: 3 },
useBuiltIns: 'usage',
targets: [
'last 2 versions',
'> 5%',
'IE 11',
'not dead'
]
}]
]
}
};
} else {
babelLoader = {
test: /\.(cjs|mjs|js)$/,
loader: 'babel-loader',
exclude: [
/@babel\//,
/\bcore-js\b/,
/\bwebpack\/buildin\b/
],
options: {
sourceType: 'unambiguous',
plugins: [
['@babel/plugin-proposal-class-properties'],
['@babel/plugin-transform-private-methods']
]
}
};
}
return {
entry,
output: {
filename,
library: 'GenesysCloudStreamingClient',
libraryTarget: 'window',
libraryExport: 'default',
path: Path.resolve(versionDir)
},
module: {
rules: [
babelLoader || {}
]
},
plugins: [
new webpack.ProvidePlugin({
process: 'process-fast'
})
]
};
};
module.exports.browserFilename = browserFilename;
module.exports.ieFilename = ieFilename;
module.exports.version = version;
module.exports.versionDir = versionDir;
module.exports.majorVersion = majorVersion;
module.exports.majorVersionDir = majorVersionDir;