Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

4x webpack build config #5111

Merged
merged 15 commits into from
Jun 16, 2022
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]
},
"scripts": {
"build": "yarn clean && lerna run build --stream",
"build": "yarn clean && lerna run build --stream && webpack --config webpackprod.config.js",
"clean": "lerna run clean --stream --parallel",
"ganache:start": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start",
"ganache:start:background": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start 1",
Expand All @@ -59,14 +59,18 @@
},
"devDependencies": {
"@cypress/webpack-preprocessor": "^5.11.1",
"@droppedcode/typedoc-plugin-relative-includes": "^1.0.2",
"@openzeppelin/contracts": "^4.6.0",
"@types/node": "*",
"@types/node": "^17.0.40",
"@types/webpack": "^5.28.0",
"assert": "^2.0.0",
"buffer": "^6.0.3",
"bufferutil": "^4.0.6",
"clean-webpack-plugin": "^4.0.0",
"crypto-browserify": "^3.12.0",
"cypress": "^9.6.0",
"cypress-jest-adapter": "^0.1.1",
"declaration-bundler-webpack-plugin": "^1.0.3",
"eslint": "^8.3.0",
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
Expand All @@ -79,17 +83,17 @@
"process": "^0.11.10",
"solc": "^0.8.13",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.8",
"ts-loader": "^9.3.0",
"ts-node": "^10.4.0",
"typescript": "^4.5.2",
"typedoc": "^0.22.15",
"typedoc-plugin-markdown": "^3.12.1",
"typedoc-monorepo-link-types": "^0.0.2",
"typedoc-plugin-extras": "^2.2.3",
"@droppedcode/typedoc-plugin-relative-includes": "^1.0.2",
"typedoc-plugin-markdown": "^3.12.1",
"typedoc-plugin-mdn-links": "^1.0.6",
"typescript": "^4.5.2",
"utf-8-validate": "^5.0.9",
"webpack": "^5.72.0"
"webpack": "^5.73.0",
"webpack-cli": "^4.9.2"
},
"packageManager": "[email protected]"
}
68 changes: 68 additions & 0 deletions webpackprod.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const webpack = require('webpack');
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

const config = {
mode: 'production',
entry: path.resolve(__dirname, 'packages/web3/src/index.ts'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'web3.min.js',
library: 'Web3',
libraryExport: 'default',
libraryTarget: 'umd',
globalObject: 'this',
},

module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: ['/node_modules/', '/unit/'],
},
],
},
resolve: {
extensions: ['.ts', '.js'],
fallback: {
child_process: false,
fs: false,
net: false,
path: false,
os: false,
util: require.resolve('util'),
http: require.resolve('http-browserify'),
https: require.resolve('https-browserify'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('readable-stream'),
},
alias: {
// To avoid blotting up the `bn.js` library all over the packages
// use single library instance.
'bn.js': path.resolve(__dirname, 'node_modules/bn.js'),
},
},
devtool: 'source-map',
plugins: [
new CleanWebpackPlugin({
verbose: true,
}),
new webpack.IgnorePlugin({
checkResource(resource) {
// "@ethereumjs/common/genesisStates" consists ~800KB static files which are no more needed
return /(.*\/genesisStates\/.*\.json)/.test(resource);
},
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
};

module.exports = () => {
return config;
};
Loading