-
Notifications
You must be signed in to change notification settings - Fork 20
/
webpack.config.js
41 lines (39 loc) · 1.01 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
const path = require('path');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const LIBRARY_NAME = 'rpc';
const OUTPUT_FILE = 'rage-rpc.min.js';
module.exports = mode => ({
entry: './src/index.ts',
mode,
module: {
rules: [
{
test: /\.ts$/,
loader: 'babel-loader'
}
]
},
resolve: {
extensions: ['.ts']
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: OUTPUT_FILE,
library: LIBRARY_NAME,
libraryTarget: 'umd',
globalObject: "typeof self !== 'undefined' ? self : this"
},
plugins: [
new ReplaceInFileWebpackPlugin([{
dir: 'dist',
files: [OUTPUT_FILE],
rules: [{
search: `exports.${LIBRARY_NAME}`,
replace: 'exports'
}, {
search: `exports["${LIBRARY_NAME}"]`,
replace: 'exports'
}]
}])
]
});