-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
31 lines (28 loc) · 960 Bytes
/
Copy pathwebpack.config.js
File metadata and controls
31 lines (28 loc) · 960 Bytes
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
const resolve = require('path').resolve;
// References:
// https://webpack.js.org/configuration/configuration-types/
// https://webpack.js.org/guides/author-libraries/
function createDevOrProdBuild(_, args) {
const BUILD_MODE = args.mode;
const isCorrectBuildMode =
BUILD_MODE === 'development' || BUILD_MODE === 'production';
if (isCorrectBuildMode)
return {
entry: resolve(__dirname, 'packages', 'calculator', 'index.js'),
output: {
path: resolve(__dirname, 'dist'),
filename: 'calculator.' + BUILD_MODE + '.js',
library: {
name: 'calculator',
type: 'umd',
},
// https://stackoverflow.com/questions/64639839/typescript-webpack-library-generates-referenceerror-self-is-not-defined
globalObject: 'this',
},
};
else
throw new Error(
'Please provide correct build mode, received: ' + BUILD_MODE
);
}
module.exports = createDevOrProdBuild;