-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.js
62 lines (55 loc) · 1.55 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
const path = require('path');
module.exports = (env) => {
const minimize = env && env.production;
const mode = minimize ? 'production' : 'development';
let filename = 'softhphone-vendor-headsets';
let babelExcludes = [];
let babelOptions;
let externals = [];
/* if we are building for 'module', don't polyfill, transpile, or bundle any dependencies – except stanza because it has node deps... */
babelExcludes = [/node_modules\/(?!(core\-util\-is)).*/];
babelOptions = {
sourceType: 'unambiguous',
presets: [
'@babel/preset-env',
'@babel/preset-typescript'
],
plugins: [
'@babel/plugin-proposal-class-properties'
]
};
filename += minimize ? '.min.js' : '.js';
console.log(`build mode: ${mode}`);
return {
target: 'web',
entry: './react-app/src/library/index.ts',
mode,
optimization: {
minimize
},
externals,
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename,
library: 'SoftphoneVendorHeadsets',
// TODO: exporting the SDK class here does not allow CDN imports access to any
// other files/modules of this lib. See: https://inindca.atlassian.net/browse/PCM-1708
libraryExport: '',
libraryTarget: 'umd'
},
resolve: {
extensions: ['.ts', '.js', '.cjs', '.mjs', '.json']
},
module: {
rules: [
{
test: /\.(cjs|mjs|js|ts)$/,
loader: 'babel-loader',
exclude: babelExcludes,
options: babelOptions
}
]
}
};
};