-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-webpack.config.ts
51 lines (45 loc) · 1.44 KB
/
custom-webpack.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { CustomWebpackBrowserSchema, TargetOptions } from '@angular-builders/custom-webpack';
import * as webpack from 'webpack';
import * as path from 'path';
import * as fs from 'fs';
export default (
config: webpack.Configuration,
_: CustomWebpackBrowserSchema,
targetOptions: TargetOptions
) => {
config.resolve.fallback = {
...config.resolve.fallback,
querystring: require.resolve('querystring-es3'),
zlib: require.resolve('browserify-zlib')
};
if (targetOptions.configuration === 'sdk') {
const sdkDirectory = '../rubic-sdk/';
const sdkDirectoryExists = fs.existsSync(sdkDirectory);
const sdkBundle = '../rubic-sdk/dist/rubic-sdk.min.js';
const sdkBundleExists = fs.existsSync(sdkBundle);
if (sdkDirectoryExists) {
if (sdkBundleExists) {
config.resolve.alias = {
...config.resolve.alias,
'rubic-sdk': path.resolve(__dirname, sdkDirectory)
};
} else {
throw new Error(
`SDK bundle is not found. Run 'yarn build & yarn compile' in sdk directory first.`
);
}
} else {
throw new Error(
'Rubic SDK directory is not exists. Clone Rubic SDK repo to ./rubic-sdk/ directory.'
);
}
}
config.resolve.alias = {
...config.resolve.alias,
'@walletconnect/ethereum-provider': path.resolve(
__dirname,
'node_modules/@walletconnect/ethereum-provider/dist/index.umd.js'
)
};
return config;
};