generated from RedHatInsights/frontend-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 7
/
fec.config.js
96 lines (92 loc) · 3.34 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
// Based on https://github.com/RedHatInsights/frontend-components/blob/master/packages/config/src/scripts/dev.webpack.config.js
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: '/business-services/hybrid-committed-spend',
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,
useCache: true,
useProxy: 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}` },
}),
},
};