Skip to content

Commit

Permalink
Merge pull request #1468 from ethereum-push-notification-service/test…
Browse files Browse the repository at this point in the history
…ing-local-library

Testing local library
  • Loading branch information
HarshRajat authored Mar 23, 2024
2 parents ec9817d + a8664f4 commit b82e5c5
Show file tree
Hide file tree
Showing 8 changed files with 6,815 additions and 5,680 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ celerybeat-schedule
env/
venv/
ENV/
.localsdk.env

# Spyder project settings
.spyderproject
Expand Down
9 changes: 9 additions & 0 deletions .localsdk.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# TO SETUP LOCAL SDK
# ENFORCE_WEBPACK_LOCAL - CAN BE TRUE OR FALSE
ENFORCE_WEBPACK_LOCAL=TRUE_or_FALSE

# NEED ABSOLUTE PATH TO DIST UIWEB PACKAGE
LOCAL_PUSH_SDK_UIWEB_ABS_PATH=absolute_path

# STORAGE FOR RESTORING
STORAGE_FOR_RESTORING_PACKAGE_JSON=autopopulated_from_package_json
56 changes: 46 additions & 10 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
const webpack = require('webpack');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

const smp = new SpeedMeasurePlugin();

const fs = require('fs'); // Adjusted to CommonJS

// for local sdk linking
let path = '';
let ModuleScopePlugin = '';

// to read and modify webpack config based on local sdk linking or production
let localSDKLinking = false;
const envpath = `./.localsdk.env`;

if (fs.existsSync(envpath)) {
const { parse } = require('envfile'); // Adjusted to CommonJS

const envData = fs.readFileSync(envpath, 'utf8');
const envObject = parse(envData);

if (envObject['ENFORCE_WEBPACK_LOCAL'] === 'TRUE') {
localSDKLinking = true;
}
}

if (localSDKLinking) {
path = require('path');
ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
}

module.exports = {
webpack: (config, env) => {
webpack: (config, env) => {
// DEV LOCAL SDK MODE STUFF
if (localSDKLinking) {
config.resolve.plugins = config.resolve.plugins.filter((plugin) => !(plugin instanceof ModuleScopePlugin));
config.resolve.alias = {
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
};
}

// do stuff with the webpack config...
config.resolve.fallback = {
assert: require.resolve('assert'),
Expand All @@ -21,24 +56,25 @@ module.exports = {
url: require.resolve('url'),
util: require.resolve('util/'),
stream: require.resolve('stream-browserify'),
zlib: require.resolve("browserify-zlib")
zlib: require.resolve('browserify-zlib'),
};
// config.devtool = false;
config.resolve.extensions = [...config.resolve.extensions, '.ts', '.js'];

config.plugins = [
...config.plugins,
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
Buffer: ['buffer', 'Buffer'],
}),
];
config.module.rules = [...config.module.rules,
config.module.rules = [
...config.module.rules,
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
fullySpecified: false,
},
},
];
config.optimization.minimizer = [
new TerserPlugin({
Expand All @@ -50,4 +86,4 @@ module.exports = {

return config;
},
}
};
Loading

0 comments on commit b82e5c5

Please sign in to comment.