forked from Cryptorubic/rubic-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-webpack.config.ts
37 lines (33 loc) · 1.07 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
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
) => {
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.'
);
}
}
return config;
};