Files
xahau.js/test/webpack.config.js
Mayukha Vadari 61b2cb7fb6 build: reduce webpack size of bip39 (#1747)
* remove non-english wordlists from bip39

* add webpack change to tests

* add bundlephobia badge
2021-10-18 18:10:14 -04:00

84 lines
2.0 KiB
JavaScript

'use strict'
const path = require('path')
const webpack = require('webpack')
const assert = require('assert')
function webpackForTest(testFileName) {
const match = testFileName.match(/\/?([^\/]*)\.ts$/)
if (!match) {
assert(false, 'wrong filename:' + testFileName)
}
const test = {
mode: 'production',
cache: true,
externals: [
{
'xrpl-local': 'xrpl',
net: 'null',
},
],
entry: testFileName,
output: {
library: match[1].replace(/-/g, '_'),
path: path.join(__dirname, './testCompiledForWeb/'),
filename: match[1] + '.js',
},
plugins: [
new webpack.ProvidePlugin({ process: 'process/browser' }),
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/wordlists\/(?!english)/,
contextRegExp: /bip39\/src$/,
}),
],
module: {
rules: [
{
test: /jayson/,
use: 'null',
},
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: {
composite: false,
declaration: false,
declarationMap: false,
},
},
},
],
},
],
},
node: {
global: true,
__filename: false,
__dirname: true,
},
resolve: {
alias: {
ws: './dist/npm/client/wsWrapper.js',
'https-proxy-agent': false,
},
extensions: ['.ts', '.js', '.json'],
fallback: {
buffer: require.resolve('buffer/'),
assert: require.resolve('assert/'),
url: require.resolve('url/'),
stream: require.resolve('stream-browserify'),
crypto: require.resolve('crypto-browserify'),
path: require.resolve('path-browserify'),
http: require.resolve('stream-http'),
},
},
}
return test
}
module.exports = [(env, argv) => webpackForTest('./test/integration/index.ts')]