This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
rage-framework-rpc/webpack.config.js

41 lines
1.0 KiB
JavaScript
Raw Normal View History

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
module.exports = mode => ({
2019-01-10 23:57:44 +00:00
entry: './src/index.ts',
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
}]
}])
]
});