Part of https://plan.wireit.in/deepstack/browse/VUL-251/ Co-authored-by: Pranav <jadhavpranav89@gmail.com> Reviewed-on: LaconicNetwork/zenith-wallet-web#10
74 lines
2.0 KiB
JavaScript
74 lines
2.0 KiB
JavaScript
// TODO: Use Typescript
|
|
const webpack = require('webpack')
|
|
|
|
module.exports = function override(config, env) {
|
|
config.module.rules.push({
|
|
test: /\.js$/,
|
|
exclude: /node_modules[/\\](?!react-native-vector-icons)/,
|
|
use: {
|
|
loader: "babel-loader",
|
|
options: {
|
|
// Disable reading babel configuration
|
|
babelrc: false,
|
|
configFile: false,
|
|
|
|
// The configuration for compilation
|
|
presets: [
|
|
["@babel/preset-env", { useBuiltIns: "usage", "corejs": "3" }],
|
|
"@babel/preset-react",
|
|
"@babel/preset-flow",
|
|
"@babel/preset-typescript",
|
|
],
|
|
plugins: [
|
|
"@babel/plugin-proposal-class-properties",
|
|
"@babel/plugin-proposal-object-rest-spread",
|
|
"@babel/plugin-transform-modules-commonjs"
|
|
]
|
|
}
|
|
}
|
|
});
|
|
|
|
config.plugins.push(
|
|
new webpack.ProvidePlugin({
|
|
Buffer: ["buffer", "Buffer"],
|
|
}),
|
|
require("@import-meta-env/unplugin").webpack({
|
|
example: ".env.example",
|
|
env: ".env",
|
|
}),
|
|
)
|
|
|
|
config.module.rules.push({
|
|
test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/,
|
|
type: 'asset/resource'
|
|
})
|
|
|
|
config.resolve.fallback = {
|
|
crypto: require.resolve("crypto-browserify"),
|
|
stream: require.resolve("stream-browserify"),
|
|
http: require.resolve('stream-http'),
|
|
https: require.resolve('https-browserify'),
|
|
vm: require.resolve('vm-browserify'),
|
|
url: false
|
|
}
|
|
|
|
config.resolve.alias['react-native$'] = require.resolve('react-native-web');
|
|
|
|
// Ignore source map warnings from third-party packages. Ref: https://github.com/facebook/create-react-app/discussions/11767#discussioncomment-3416044
|
|
const ignoreSourceMapPackages = [
|
|
'@cosmjs',
|
|
'@confio/ics23',
|
|
'@json-rpc-tools',
|
|
'@pedrouid/environment',
|
|
'@walletconnect',
|
|
'cosmjs-types',
|
|
];
|
|
|
|
config.ignoreWarnings = ignoreSourceMapPackages.map(pkg => ({
|
|
module: new RegExp(`node_modules/${pkg.replace('/', '\\/')}`),
|
|
message: /Failed to parse source map/,
|
|
}));
|
|
|
|
return config;
|
|
};
|