-
Notifications
You must be signed in to change notification settings - Fork 39
/
fec.config.js
123 lines (119 loc) · 4.31 KB
/
fec.config.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// Based on https://github.com/RedHatInsights/frontend-components/blob/master/packages/config/src/bin/dev.webpack.config.ts
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const { dependencies, insights } = require('./package.json');
const moduleName = insights.appname.replace(/-(\w)/g, (_, match) => match.toUpperCase());
const srcDir = path.resolve(__dirname, './src');
const distDir = path.resolve(__dirname, './dist/');
const fileRegEx = /\.(png|woff|woff2|eot|ttf|svg|gif|jpe?g|png)(\?[a-z0-9=.]+)?$/;
const stats = {
excludeAssets: fileRegEx,
colors: true,
modules: false,
};
// Show what files changed since last compilation
class WatchRunPlugin {
apply(compiler) {
compiler.hooks.watchRun.tap('WatchRun', comp => {
if (comp.modifiedFiles) {
const changedFiles = Array.from(comp.modifiedFiles, file => `\n ${file}`).join('');
const logger = compiler.getInfrastructureLogger(insights.appname);
logger.info(' ');
logger.info('===============================');
logger.info('FILES CHANGED:', changedFiles);
logger.info('===============================');
}
});
}
}
module.exports = {
appUrl: '/openshift/cost-management',
debug: true,
interceptChromeConfig: false, // Change to false after your app is registered in configuration files
proxyVerbose: true,
sassPrefix: `.${moduleName}`,
// sassPrefix: 'body', // For PF v5 testing only
// bundlePfModules: true, // See https://console.stage.redhat.com/platform-docs/frontend-components/proxies/webpack-proxy#includePFcssmodulesinyourbundle
stats,
standalone: process.env.LOCAL_API_PORT ? true : false,
useCache: true,
useProxy: process.env.LOCAL_API_PORT ? false : true,
/**
* Temporarily disabled HMR -- see https://issues.redhat.com/browse/COST-3224
*
...(process.env.HMR && { _unstableHotReload: process.env.HMR === 'true' }),
*/
/**
* Config for federated modules
*/
moduleFederation: {
moduleName,
/**
* There is a know issue with apps using yarn to build their applications that the router package is not properly shared
* Same issue was encountered in application services
* Package can be re-enabled for sharing once chrome starts providing global routing package to all applications
*/
// exclude: ['react-router-dom'],
exposes: {
'./RootApp': path.resolve(__dirname, './src/appEntry.tsx'),
},
shared: [
{ 'react-redux': { version: dependencies['react-redux'] } },
{ 'react-router-dom': { version: dependencies['react-router-dom'], import: false, singleton: true } },
{ '@unleash/proxy-client-react': { version: dependencies['@unleash/proxy-client-react'], singleton: true } },
],
},
/**
* Add additional webpack plugins
*/
plugins: [
new WatchRunPlugin(),
new webpack.ProgressPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: path.join(srcDir, 'locales'),
to: path.join(distDir, 'locales'),
},
],
}),
],
resolve: {
modules: [srcDir, path.resolve(__dirname, './node_modules')],
},
routes: {
/**
* Chrome services backend config routes, typically localhost:8000
*/
...(process.env.CLOUD_SERVICES_BACKEND_PORT && {
'/api/chrome-service/v1/static': { host: `http://localhost:${process.env.CLOUD_SERVICES_BACKEND_PORT}` },
}),
/**
* Ephemeral routes, typically localhost:8000
*/
...(process.env.EPHEMERAL_PORT && {
'/api/cost-management/v1/': { host: `http://localhost:${process.env.EPHEMERAL_PORT}` },
}),
/**
* Local API routes, typically localhost:8000
*/
...(process.env.LOCAL_API_PORT && {
'/api/cost-management/v1/': {
host: `http://${process.env.LOCAL_API_HOST || 'localhost'}:${process.env.LOCAL_API_PORT}`,
},
}),
/**
* FEC static routes, typically localhost:8003
* https://console.stage.redhat.com/platform-docs/frontend-components/proxies/webpack-proxy#Inventoryexample
*/
...(process.env.FEC_STATIC_PORT && {
'/apps/cost-management-mfe': {
host: `http://localhost:${process.env.FEC_STATIC_PORT}`,
},
'/beta/apps/cost-management-mfe': {
host: `http://localhost:${process.env.FEC_STATIC_PORT}`,
},
}),
},
};