forked from Crestron/CH5ComponentLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.config.js
60 lines (52 loc) · 1.72 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
const webpackMerge = require('webpack-merge');
const webpackCommon = require('./webpack.common.config');
const moduleTypes = ['cjs', 'umd', 'amd']; // 'esm' cannot be obtained from webpack, will be compiled with tsc
let moduleType = 'umd'; // UMD includes commonjs, amd and attaching a property to the window object
if (process.env.MODULE_TYPE && moduleTypes.indexOf(process.env.MODULE_TYPE) >= 0) {
moduleType = process.env.MODULE_TYPE;
}
let libraryTarget = 'umd';
switch (moduleType) {
case 'cjs':
libraryTarget = 'commonjs2';
break;
case 'amd':
libraryTarget = 'amd';
break;
default:
libraryTarget = 'umd';
break;
}
const NO_CE = process.env.NO_CE;
let moduleBuildFolder = moduleType;
if (NO_CE === '1') { // for browsers that do not support customElements
moduleBuildFolder = moduleType + '-no-ce';
}
const path = require('path');
const basePath = path.resolve(__dirname);
let buildPath = path.resolve(basePath, 'build_bundles', moduleBuildFolder);
const CI = process.env.CI;
if (CI) {
buildPath = path.resolve(basePath, 'build_bundles_dev', moduleBuildFolder);
}
module.exports = function () {
return webpackMerge(webpackCommon(), {
mode: 'development',
target: 'web',
output: {
path: buildPath,
filename: '[name].js',
libraryTarget: libraryTarget,
library: 'CrComLib',
// in case we need different names:
// library: {
// root: "CrComLib",
// amd: "CrComLib",
// commonjs: "CrComLib"
// },
umdNamedDefine: true
},
devtool: 'inline-source-map'
// , stats: 'verbose'
})
};