Files
bitget-api/webpack/webpack.config.js
2024-12-11 16:40:54 +00:00

73 lines
1.8 KiB
JavaScript

const path = require('path');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
function generateConfig(name) {
var config = {
entry: './lib/index.js',
output: {
path: path.resolve(__dirname, '../dist'),
filename: name + '.js',
sourceMapFilename: name + '.map',
library: name,
libraryTarget: 'umd',
},
devtool: 'source-map',
mode: 'production',
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: ['.webpack.js', '.web.js', '.ts', '.tsx', '.js'],
alias: {
[path.resolve(__dirname, '../lib/util/node-support.js')]: path.resolve(
__dirname,
'../lib/util/browser-support.js',
),
},
},
module: {
rules: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{ test: /\.tsx?$/, loader: 'ts-loader' },
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{ test: /\.js$/, loader: 'source-map-loader' },
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components|samples|lib|test|coverage)/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
},
},
},
],
},
};
config.plugins = [
new BundleAnalyzerPlugin({
defaultSizes: 'stat',
analyzerMode: 'static',
reportFilename: '../doc/bundleReport.html',
openAnalyzer: false,
}),
];
return config;
}
module.exports = generateConfig('bitgetapi');