-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
45 lines (41 loc) · 1.16 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
const path = require('path'),
yargs = require('yargs');
const isProductionBuild = yargs.argv.mode === 'production';
const commonConfig = {
devtool: isProductionBuild ? 'none' : 'source-map',
resolve: {
// Add '.ts' and '.tsx' as a resolvable extension.
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
{test: /\.tsx?$/, loader: "ts-loader"}
]
}
};
// Bundle configuration: this includes both OPRF and libsodium
const bundle = Object.assign({
entry: './src/oprf.ts',
output: {
filename: 'oprf.js',
path: path.resolve(__dirname, 'dist'),
library: 'OPRF',
libraryTarget: 'var'
}
}, commonConfig);
// Slim configuration: only include OPRF, and require libsodium be passed to constructor
const slim = Object.assign({
entry: './src/oprf.slim.ts',
output: {
filename: 'oprf.slim.js',
path: path.resolve(__dirname, 'dist'),
library: 'OPRF',
libraryTarget: 'var',
libraryExport: 'OPRFSlim' // Expose OPRFSlim module so we don't have to call new OPRF.OPRFSlim()
}
}, commonConfig);
module.exports = [
bundle,
slim
];