2018-11-02 05:10:24 +00:00
|
|
|
const path = require('path');
|
2019-02-03 01:46:00 +00:00
|
|
|
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
|
|
|
|
|
|
|
|
const LIBRARY_NAME = 'rpc';
|
|
|
|
const OUTPUT_FILE = 'rage-rpc.min.js';
|
2018-11-02 05:10:24 +00:00
|
|
|
|
2019-03-06 20:01:37 +00:00
|
|
|
module.exports = mode => ({
|
2019-01-10 23:57:44 +00:00
|
|
|
entry: './src/index.ts',
|
2019-03-06 20:01:37 +00:00
|
|
|
mode,
|
2019-01-10 23:57:44 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: 'babel-loader'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts']
|
|
|
|
},
|
2018-11-02 05:10:24 +00:00
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, 'dist'),
|
2019-02-03 01:46:00 +00:00
|
|
|
filename: OUTPUT_FILE,
|
|
|
|
library: LIBRARY_NAME,
|
2018-11-02 05:29:47 +00:00
|
|
|
libraryTarget: 'umd',
|
|
|
|
globalObject: "typeof self !== 'undefined' ? self : this"
|
2019-02-03 01:46:00 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new ReplaceInFileWebpackPlugin([{
|
|
|
|
dir: 'dist',
|
|
|
|
files: [OUTPUT_FILE],
|
|
|
|
rules: [{
|
|
|
|
search: `exports.${LIBRARY_NAME}`,
|
|
|
|
replace: 'exports'
|
2019-02-11 05:07:13 +00:00
|
|
|
}, {
|
|
|
|
search: `exports["${LIBRARY_NAME}"]`,
|
|
|
|
replace: 'exports'
|
2019-02-03 01:46:00 +00:00
|
|
|
}]
|
|
|
|
}])
|
|
|
|
]
|
2019-03-06 20:01:37 +00:00
|
|
|
});
|