-
Notifications
You must be signed in to change notification settings - Fork 145
/
webpack.config.js
70 lines (65 loc) · 2.2 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
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const LicenseWebpackPlugin = require('license-webpack-plugin').LicenseWebpackPlugin;
const path = require('path');
const webpack = require('webpack');
const packageJson = require('./package.json');
const fs = require('fs');
const version = packageJson.version;
console.log(`Package version: ${version}`);
module.exports = {
entry: {
main: path.resolve(__dirname, 'src/index.ts'),
},
output: {
library: 'KVSWebRTC',
libraryTarget: 'window',
},
externals: {
'isomorphic-webcrypto': 'crypto',
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
// disable type checker - we will use it in fork plugin
transpileOnly: true,
},
},
],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.EnvironmentPlugin({
PACKAGE_VERSION: version,
}),
new LicenseWebpackPlugin({
outputFilename: 'kvs-webrtc.LICENSE',
addBanner: true,
renderBanner: () => fs.readFileSync('./license/bundleLicenseBanner.txt', { encoding: 'utf-8' }).replace('VERSION', version),
renderLicenses: modules => {
let text = fs.readFileSync('./license/bundleLicenseHeader.txt', { encoding: 'utf-8' });
modules.forEach(module => {
text += '\n';
text += `This product bundles ${module.name}, which is available under the ${module.licenseId} license:\n`;
text += '\n';
text += module.licenseText
.split('\n')
.map(line => ` ${line}\n`)
.join('');
});
return text;
},
}),
],
// Fail if there are any errors (such as a TypeScript type issue)
bail: true,
};