forked from webex/webex-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
135 lines (130 loc) · 4.95 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
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
const path = require('path');
const dotenv = require('dotenv');
const glob = require('glob');
const {BannerPlugin, DefinePlugin, EnvironmentPlugin} = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const {version} = require('./packages/node_modules/webex/package.json');
dotenv.config();
dotenv.config({path: '.env.default'});
module.exports = (env = process.env.NODE_ENV || 'production', args) => ({
entry: env === 'development' ?
`${path.resolve(__dirname)}/packages/node_modules/webex/src/index.js` :
'./packages/node_modules/webex',
mode: env === 'development' ? 'development' : 'production',
output: {
filename: 'webex.min.js',
library: 'Webex',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
path: args && args.umd ? // samples:test fix since its called as a function
`${path.resolve(__dirname)}/packages/node_modules/webex/umd` :
`${path.resolve(__dirname)}/packages/node_modules/samples`
},
devtool: env === 'development' ? 'cheap-module-source-map' : 'source-map',
devServer: {
https: true,
disableHostCheck: true,
port: 8000,
contentBase: './packages/node_modules/samples',
stats: {
colors: true
}
},
node: {
fs: 'empty'
},
resolve: {
alias: glob
.sync('**/package.json', {cwd: './packages/node_modules'})
.map((p) => path.dirname(p))
.reduce((alias, packageName) => {
// Always use src as the entry point for local files so that we have the
// best opportunity for treeshaking; also makes developing easier since
// we don't need to manually rebuild after changing code.
alias[`./packages/node_modules/${packageName}`] = path.resolve(
__dirname,
`./packages/node_modules/${packageName}/src/index.js`
);
alias[`${packageName}`] = path.resolve(__dirname, `./packages/node_modules/${packageName}/src/index.js`);
return alias;
}, {})
},
module: {
rules: [
{
test: /\.js$/,
include: /packages\/node_modules/,
use: {
loader: 'babel-loader'
}
}
]
},
...(env !== 'development' && {
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
cache: true,
extractComments: false,
parallel: true,
sourceMap: true,
terserOptions: {
output: {
preamble: `/*! Webex JS SDK v${process.env.VERSION || version} */`,
comments: false
}
}
})
]
}
}),
plugins: [
// If in integration and building for production (not testing) use production URLS
...(env === 'test' ?
[
// Environment Plugin doesn't override already defined Environment Variables (i.e. DotENV)
new EnvironmentPlugin({
WEBEX_LOG_LEVEL: 'log',
DEBUG: '',
NODE_ENV: 'production',
// The following environment variables are specific to our continuous
// integration process and should not be used in general
ATLAS_SERVICE_URL: 'https://atlas-intb.ciscospark.com/admin/api/v1',
CONVERSATION_SERVICE: 'https://conversation-intb.ciscospark.com/conversation/api/v1',
ENCRYPTION_SERVICE_URL: 'https://encryption-intb.ciscospark.com/encryption/api/v1',
HYDRA_SERVICE_URL: 'https://apialpha.ciscospark.com/v1/',
IDBROKER_BASE_URL: 'https://idbrokerbts.webex.com',
IDENTITY_BASE_URL: 'https://identitybts.webex.com',
U2C_SERVICE_URL: 'https://u2c-intb.ciscospark.com/u2c/api/v1',
WDM_SERVICE_URL: 'https://wdm-intb.ciscospark.com/wdm/api/v1',
WHISTLER_API_SERVICE_URL: 'https://whistler.onint.ciscospark.com/api/v1'
})
] : [
new BannerPlugin({
banner: `Webex JS SDK v${process.env.VERSION || version}`
}),
new EnvironmentPlugin({
WEBEX_LOG_LEVEL: 'log',
DEBUG: '',
NODE_ENV: env === 'development' ? 'development' : 'production'
}),
// This allows overwriting of process.env
new DefinePlugin({
'process.env': {
// Use production URLs with samples
ATLAS_SERVICE_URL: JSON.stringify('https://atlas-a.wbx2.com/admin/api/v1'),
CONVERSATION_SERVICE: JSON.stringify('https://conv-a.wbx2.com/conversation/api/v1'),
ENCRYPTION_SERVICE_URL: JSON.stringify('https://encryption-a.wbx2.com'),
HYDRA_SERVICE_URL: JSON.stringify('https://api.ciscospark.com/v1'),
IDBROKER_BASE_URL: JSON.stringify('https://idbroker.webex.com'),
IDENTITY_BASE_URL: JSON.stringify('https://identity.webex.com'),
U2C_SERVICE_URL: JSON.stringify('https://u2c.wbx2.com/u2c/api/v1'),
WDM_SERVICE_URL: JSON.stringify('https://wdm-a.wbx2.com/wdm/api/v1'),
WHISTLER_API_SERVICE_URL: JSON.stringify('https://whistler-prod.onint.ciscospark.com/api/v1')
}
})
]
)
]
});