@redhat-cloud-services/frontend-components-config 4.5.9 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/bin/fec.js +33 -2
- package/index.js +67 -63
- package/package.json +7 -2
- package/src/config.js +186 -162
- package/src/config.test.js +86 -109
- package/src/plugins.js +50 -45
- package/src/plugins.test.js +31 -35
- package/src/scripts/common.js +7 -0
- package/src/scripts/csc-interceptor-server.js +70 -0
- package/src/scripts/dev-script.js +102 -0
- package/src/scripts/dev.webpack.config.js +62 -0
- package/src/scripts/empty.js +2 -0
- package/src/scripts/prod.webpack.config.js +19 -0
- package/src/scripts/webpack.plugins.js +14 -0
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- [Removed features with webpack 5](#removed-features-with-webpack-5)
|
|
8
8
|
- [useProxy](#useproxy)
|
|
9
9
|
- [Attributes](#attributes)
|
|
10
|
+
- [useChromeTemplate](#useChromeTemplate)
|
|
10
11
|
- [localChrome](#localchrome)
|
|
11
12
|
- [registry](#registry)
|
|
12
13
|
- [Custom routes](#custom-routes)
|
|
@@ -54,6 +55,7 @@ const { config: webpackConfig, plugins } = config({
|
|
|
54
55
|
|---------|----|-----------|
|
|
55
56
|
|[useProxy](#useproxy)|`boolean`|Enables webpack proxy.|
|
|
56
57
|
|[proxyURL](#proxyURL)|`string`|URL to proxy Akamai environment requests to.|
|
|
58
|
+
|[useChromeTemplate](#useChromeTemplate)|`boolean`|Load chrome HTMl template.|
|
|
57
59
|
|[localChrome](#localChrome)|`string`|Path to your local chrome build folder.|
|
|
58
60
|
|[keycloakUri](#keycloakUri)|`string`|Uri to inject into proxied chrome assets.|
|
|
59
61
|
|[registry](#registry)|`(({ app, server, compiler, standaloneConfig }) => void)[]`|Express middleware to register.|
|
|
@@ -64,6 +66,24 @@ const { config: webpackConfig, plugins } = config({
|
|
|
64
66
|
|[useCloud](#use-cloud)|`boolean`|Toggle to use old fallback to cloud.redhat.com paths instead of console.redhat.com.|
|
|
65
67
|
|[target](#target)|`string`|Override `env` and `useCloud` to use a custom URI.|
|
|
66
68
|
|
|
69
|
+
|
|
70
|
+
#### useChromeTemplate
|
|
71
|
+
|
|
72
|
+
**This option will become the default. App-specific templates are deprecated**
|
|
73
|
+
|
|
74
|
+
To load chrome HTML template instead of using the APP-specific template add `useChromeTemplate` flag to your config.
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
const config = require('@redhat-cloud-services/frontend-components-config');
|
|
78
|
+
|
|
79
|
+
const { config: webpackConfig, plugins } = config({
|
|
80
|
+
rootFolder: resolve(__dirname, '../'),
|
|
81
|
+
useProxy: true,
|
|
82
|
+
useChromeTemplate: true
|
|
83
|
+
...
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
67
87
|
#### localChrome
|
|
68
88
|
|
|
69
89
|
You can also easily run you application with a local build of Chrome by adding `localChrome: <absolute_path_to_chrome_build_folder>`.
|
|
@@ -320,6 +340,9 @@ Use binary in your `package.json` scripts section:
|
|
|
320
340
|
}
|
|
321
341
|
```
|
|
322
342
|
|
|
343
|
+
## Patch etc hosts
|
|
344
|
+
This is a required step for first time setup. It will allow your localhost to map to [env].foo.redhat.com. This is required to run only once on your machine. **Your OS may require running the script as sudo**!
|
|
345
|
+
|
|
323
346
|
## Static
|
|
324
347
|
|
|
325
348
|
A script that will run webpack build and serve webpack output through `http-serve` server. **This is not supposed to replace webpack dev server!**
|
package/bin/fec.js
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
3
|
const static = require('@redhat-cloud-services/frontend-components-config-utilities/serve-federated');
|
|
4
4
|
const yargs = require('yargs');
|
|
5
5
|
|
|
6
|
+
const devScript = require('../src/scripts/dev-script');
|
|
7
|
+
const { logError } = require('../src/scripts/common')
|
|
8
|
+
|
|
9
|
+
function patchHosts() {
|
|
10
|
+
const command = `
|
|
11
|
+
for host in prod.foo.redhat.com stage.foo.redhat.com qa.foo.redhat.com ci.foo.redhat.com
|
|
12
|
+
do
|
|
13
|
+
grep -q $host /etc/hosts 2>/dev/null
|
|
14
|
+
if [ $? -ne 0 ]
|
|
15
|
+
then
|
|
16
|
+
echo "Adding $host to /etc/hosts"
|
|
17
|
+
echo "127.0.0.1 $host" >>/etc/hosts
|
|
18
|
+
fi
|
|
19
|
+
done
|
|
20
|
+
`
|
|
21
|
+
try {
|
|
22
|
+
execSync(command)
|
|
23
|
+
} catch (error) {
|
|
24
|
+
logError('Unable to patch /etc/hosts! Please to run the script as sudo.')
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
const cwd = process.cwd();
|
|
7
29
|
|
|
8
30
|
const argv = yargs
|
|
@@ -19,11 +41,20 @@ const argv = yargs
|
|
|
19
41
|
default: 8003
|
|
20
42
|
});
|
|
21
43
|
})
|
|
44
|
+
.command('patch-etc-hosts', 'You may have to run this as \'sudo\'. Setup your etc/hosts allow development hosts in your browser')
|
|
45
|
+
.command('dev', 'Start development server', (yargs) => {
|
|
46
|
+
yargs.positional('webpack-config', {
|
|
47
|
+
type: 'string',
|
|
48
|
+
describe: 'Path to webpack config',
|
|
49
|
+
})
|
|
50
|
+
})
|
|
22
51
|
.help()
|
|
23
52
|
.argv;
|
|
24
53
|
|
|
25
54
|
const scripts = {
|
|
26
|
-
static
|
|
55
|
+
static,
|
|
56
|
+
'patch-etc-hosts': patchHosts,
|
|
57
|
+
dev: devScript
|
|
27
58
|
};
|
|
28
59
|
|
|
29
60
|
const args = [ argv, cwd ];
|
package/index.js
CHANGED
|
@@ -2,81 +2,85 @@ const config = require('./src/config');
|
|
|
2
2
|
const plugins = require('./src/plugins');
|
|
3
3
|
const { sync } = require('glob');
|
|
4
4
|
|
|
5
|
-
const gitRevisionPlugin = new(require('git-revision-webpack-plugin'))({
|
|
6
|
-
|
|
5
|
+
const gitRevisionPlugin = new (require('git-revision-webpack-plugin'))({
|
|
6
|
+
branch: true,
|
|
7
7
|
});
|
|
8
|
-
const betaBranches = [
|
|
9
|
-
const akamaiBranches = [
|
|
8
|
+
const betaBranches = ['master', 'qa-beta', 'ci-beta', 'prod-beta', 'main', 'devel', 'stage-beta'];
|
|
9
|
+
const akamaiBranches = ['prod-beta', 'prod-stable'];
|
|
10
10
|
|
|
11
11
|
const getAppEntry = (rootFolder, isProd) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (entries.length > 0) {
|
|
20
|
-
return `${rootFolder}/${entries[0]}`;
|
|
21
|
-
}
|
|
12
|
+
// Use entry-dev if it exists
|
|
13
|
+
if (!isProd) {
|
|
14
|
+
const entries = sync('src/entry-dev.{js,jsx,ts,tsx}', { cwd: rootFolder });
|
|
15
|
+
if (entries.length > 1) {
|
|
16
|
+
console.warn('Found multiple entry-dev files. Using', entries[0]);
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
console.warn('Found multiple entry files. Using', entries[0]);
|
|
19
|
+
if (entries.length > 0) {
|
|
20
|
+
return `${rootFolder}/${entries[0]}`;
|
|
27
21
|
}
|
|
22
|
+
}
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
const entries = sync('src/entry.{js,jsx,ts,tsx}', { cwd: rootFolder });
|
|
25
|
+
if (entries.length > 1) {
|
|
26
|
+
console.warn('Found multiple entry files. Using', entries[0]);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${rootFolder}/${entries[0]}`;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
module.exports = (configurations) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
configurations.isProd = configurations.isProd || process.env.NODE_ENV === 'production';
|
|
34
|
+
const isProd = configurations.isProd;
|
|
35
|
+
const { insights } = require(`${configurations.rootFolder}/package.json`);
|
|
36
|
+
let gitBranch;
|
|
37
|
+
try {
|
|
38
|
+
gitBranch = process.env.TRAVIS_BRANCH || process.env.BRANCH || gitRevisionPlugin.branch();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.log('[fec] no git branch detected, using main for webpack "main" config.');
|
|
41
|
+
gitBranch = 'main';
|
|
42
|
+
}
|
|
43
|
+
const appDeployment = configurations.deployment || (isProd && betaBranches.includes(gitBranch) ? 'beta/apps' : 'apps');
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log(`Root folder: ${configurations.rootFolder}`);
|
|
49
|
-
console.log(`Current branch: ${gitBranch}`);
|
|
50
|
-
!generateSourceMaps && console.log(`Source map generation for "${gitBranch}" deployment has been disabled.`);
|
|
51
|
-
console.log(`Beta branches: ${betaBranches}`);
|
|
52
|
-
console.log(`Using deployments: ${appDeployment}`);
|
|
53
|
-
console.log(`Public path: ${publicPath}`);
|
|
54
|
-
console.log(`App entry: ${appEntry}`);
|
|
55
|
-
console.log(`Use proxy: ${configurations.useProxy ? 'true' : 'false'}`);
|
|
56
|
-
if (!(configurations.useProxy || configurations.standalone)) {
|
|
57
|
-
console.warn('Insights-proxy is deprecated in favor of "useProxy" or "standalone".');
|
|
58
|
-
console.warn('See https://github.com/RedHatInsights/frontend-components/blob/master/packages/config/README.md');
|
|
59
|
-
}
|
|
45
|
+
const publicPath = `/${appDeployment}/${insights.appname}/`;
|
|
46
|
+
const appEntry = configurations.appEntry || getAppEntry(configurations.rootFolder, isProd);
|
|
47
|
+
const generateSourceMaps = !akamaiBranches.includes(gitBranch);
|
|
60
48
|
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
if (configurations.debug) {
|
|
50
|
+
/* eslint-disable no-console */
|
|
51
|
+
console.log('~~~Using variables~~~');
|
|
52
|
+
console.log(`Root folder: ${configurations.rootFolder}`);
|
|
53
|
+
console.log(`Current branch: ${gitBranch}`);
|
|
54
|
+
!generateSourceMaps && console.log(`Source map generation for "${gitBranch}" deployment has been disabled.`);
|
|
55
|
+
console.log(`Beta branches: ${betaBranches}`);
|
|
56
|
+
console.log(`Using deployments: ${appDeployment}`);
|
|
57
|
+
console.log(`Public path: ${publicPath}`);
|
|
58
|
+
console.log(`App entry: ${appEntry}`);
|
|
59
|
+
console.log(`Use proxy: ${configurations.useProxy ? 'true' : 'false'}`);
|
|
60
|
+
if (!(configurations.useProxy || configurations.standalone)) {
|
|
61
|
+
console.warn('Insights-proxy is deprecated in favor of "useProxy" or "standalone".');
|
|
62
|
+
console.warn('See https://github.com/RedHatInsights/frontend-components/blob/master/packages/config/README.md');
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
console.log('~~~~~~~~~~~~~~~~~~~~~');
|
|
66
|
+
/* eslint-enable no-console */
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
config: config({
|
|
71
|
+
...configurations,
|
|
72
|
+
appDeployment,
|
|
73
|
+
insights,
|
|
74
|
+
publicPath,
|
|
75
|
+
appEntry,
|
|
76
|
+
appName: insights.appname,
|
|
77
|
+
}),
|
|
78
|
+
plugins: plugins({
|
|
79
|
+
...configurations,
|
|
80
|
+
generateSourceMaps,
|
|
81
|
+
appDeployment,
|
|
82
|
+
insights,
|
|
83
|
+
publicPath,
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
82
86
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Config plugins and settings for RedHat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,14 +20,17 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/RedHatInsights/frontend-components/tree/master/packages/config#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@redhat-cloud-services/frontend-components-config-utilities": "^1.5.
|
|
23
|
+
"@redhat-cloud-services/frontend-components-config-utilities": "^1.5.9",
|
|
24
24
|
"assert": "^2.0.0",
|
|
25
|
+
"axios": "^0.25.0",
|
|
25
26
|
"babel-loader": "^8.2.2",
|
|
26
27
|
"browserify-zlib": "^0.2.0",
|
|
27
28
|
"buffer": "^6.0.3",
|
|
28
29
|
"clean-webpack-plugin": "^3.0.0",
|
|
29
30
|
"css-loader": "^5.2.6",
|
|
30
31
|
"concurrently": "^6.3.0",
|
|
32
|
+
"chalk": "^5.0.0",
|
|
33
|
+
"express": "^4.17.2",
|
|
31
34
|
"git-revision-webpack-plugin": "^3.0.6",
|
|
32
35
|
"glob": "^7.0.0",
|
|
33
36
|
"html-replace-webpack-plugin": "^2.6.0",
|
|
@@ -35,8 +38,10 @@
|
|
|
35
38
|
"https-proxy-agent": "^5.0.0",
|
|
36
39
|
"http-server": "^13.0.2",
|
|
37
40
|
"mini-css-extract-plugin": "^1.6.0",
|
|
41
|
+
"inquirer": "^8.2.0",
|
|
38
42
|
"js-yaml": "^4.0.0",
|
|
39
43
|
"jws": "^4.0.0",
|
|
44
|
+
"lodash": "^4.17.21",
|
|
40
45
|
"path-browserify": "^1.0.1",
|
|
41
46
|
"process": "^0.11.10",
|
|
42
47
|
"sass": "^1.34.1",
|
package/src/config.js
CHANGED
|
@@ -1,179 +1,203 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
3
4
|
const proxy = require('@redhat-cloud-services/frontend-components-config-utilities/proxy');
|
|
4
5
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
5
6
|
const searchIgnoredStyles = require('@redhat-cloud-services/frontend-components-config-utilities/search-ignored-styles');
|
|
6
7
|
|
|
7
8
|
module.exports = ({
|
|
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
|
-
|
|
9
|
+
port,
|
|
10
|
+
publicPath,
|
|
11
|
+
appEntry,
|
|
12
|
+
rootFolder,
|
|
13
|
+
https,
|
|
14
|
+
mode,
|
|
15
|
+
appName,
|
|
16
|
+
useFileHash = true,
|
|
17
|
+
betaEnv,
|
|
18
|
+
env,
|
|
19
|
+
sassPrefix,
|
|
20
|
+
skipChrome2 = false,
|
|
21
|
+
useProxy,
|
|
22
|
+
proxyURL,
|
|
23
|
+
localChrome,
|
|
24
|
+
keycloakUri,
|
|
25
|
+
customProxy,
|
|
26
|
+
routes,
|
|
27
|
+
routesPath,
|
|
28
|
+
isProd,
|
|
29
|
+
standalone = false,
|
|
30
|
+
reposDir,
|
|
31
|
+
appUrl = [],
|
|
32
|
+
proxyVerbose,
|
|
33
|
+
useCloud,
|
|
34
|
+
target,
|
|
35
|
+
registry,
|
|
36
|
+
client = {},
|
|
37
|
+
bundlePfModules = false,
|
|
38
|
+
useChromeTemplate = false,
|
|
37
39
|
} = {}) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const filenameMask = `js/[name]${useFileHash ? `.${Date.now()}.[fullhash]` : ''}.js`;
|
|
41
|
+
if (betaEnv) {
|
|
42
|
+
env = `${betaEnv}-beta`;
|
|
43
|
+
console.warn('betaEnv is deprecated in favor of env');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const outputPath = `${rootFolder || ''}/dist`;
|
|
47
|
+
|
|
48
|
+
const copyTemplate = (chromePath) => {
|
|
49
|
+
const template = fs.readFileSync(`${chromePath}/index.html`, { encoding: 'utf-8' });
|
|
50
|
+
if (!fs.existsSync(outputPath)) {
|
|
51
|
+
fs.mkdirSync(outputPath);
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
fs.writeFileSync(`${outputPath}/index.html`, template);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const devServerPort = typeof port === 'number' ? port : useProxy || standalone ? 1337 : 8002;
|
|
58
|
+
return {
|
|
59
|
+
mode: mode || (isProd ? 'production' : 'development'),
|
|
60
|
+
devtool: false,
|
|
61
|
+
entry: {
|
|
62
|
+
App: appEntry,
|
|
63
|
+
},
|
|
64
|
+
output: {
|
|
65
|
+
filename: filenameMask,
|
|
66
|
+
path: outputPath,
|
|
67
|
+
publicPath,
|
|
68
|
+
chunkFilename: filenameMask,
|
|
69
|
+
},
|
|
70
|
+
module: {
|
|
71
|
+
rules: [
|
|
72
|
+
{
|
|
73
|
+
test: new RegExp(appEntry),
|
|
74
|
+
loader: path.resolve(__dirname, './chrome-render-loader.js'),
|
|
75
|
+
options: {
|
|
76
|
+
appName,
|
|
77
|
+
skipChrome2,
|
|
78
|
+
},
|
|
50
79
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
chunkFilename: filenameMask
|
|
80
|
+
{
|
|
81
|
+
test: /src\/.*\.js$/,
|
|
82
|
+
exclude: /(node_modules|bower_components)/i,
|
|
83
|
+
use: ['babel-loader'],
|
|
56
84
|
},
|
|
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
|
-
options: {
|
|
86
|
-
additionalData: function(content, loaderContext) {
|
|
87
|
-
const { resourcePath, rootContext } = loaderContext;
|
|
88
|
-
const relativePath = path.relative(rootContext, resourcePath);
|
|
89
|
-
/**
|
|
90
|
-
* Add app class context for local style files.
|
|
91
|
-
* Context class is equal to app name and that class ass added to root element via the chrome-render-loader.
|
|
92
|
-
*/
|
|
93
|
-
if (relativePath.match(/^src/)) {
|
|
94
|
-
return `${sassPrefix || `.${appName}`}{\n${content}\n}`;
|
|
95
|
-
}
|
|
85
|
+
{
|
|
86
|
+
test: /src\/.*\.tsx?$/,
|
|
87
|
+
loader: 'ts-loader',
|
|
88
|
+
exclude: /(node_modules)/i,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
test: /\.s?[ac]ss$/,
|
|
92
|
+
use: [
|
|
93
|
+
MiniCssExtractPlugin.loader,
|
|
94
|
+
'css-loader',
|
|
95
|
+
{
|
|
96
|
+
/**
|
|
97
|
+
* Second sass loader used for scoping the css with class name.
|
|
98
|
+
* Has to be included as second in order to re-scope already compiled sass files.
|
|
99
|
+
* Second loader is required to avoid scoping mixins, includes and other sass partials. We want to only scope the CSS output.
|
|
100
|
+
*/
|
|
101
|
+
loader: 'sass-loader',
|
|
102
|
+
options: {
|
|
103
|
+
additionalData: function (content, loaderContext) {
|
|
104
|
+
const { resourcePath, rootContext } = loaderContext;
|
|
105
|
+
const relativePath = path.relative(rootContext, resourcePath);
|
|
106
|
+
/**
|
|
107
|
+
* Add app class context for local style files.
|
|
108
|
+
* Context class is equal to app name and that class ass added to root element via the chrome-render-loader.
|
|
109
|
+
*/
|
|
110
|
+
if (relativePath.match(/^src/)) {
|
|
111
|
+
return `${sassPrefix || `.${appName}`}{\n${content}\n}`;
|
|
112
|
+
}
|
|
96
113
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
'sass-loader'
|
|
102
|
-
]
|
|
103
|
-
}, {
|
|
104
|
-
test: /\.(woff(2)?|ttf|jpg|png|eot|gif|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
105
|
-
type: 'asset/resource',
|
|
106
|
-
generator: {
|
|
107
|
-
filename: 'fonts/[name][ext]'
|
|
108
|
-
}
|
|
114
|
+
return content;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
109
117
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
include: /node_modules/,
|
|
113
|
-
type: 'javascript/auto'
|
|
114
|
-
}]
|
|
118
|
+
'sass-loader',
|
|
119
|
+
],
|
|
115
120
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
path: require.resolve('path-browserify'),
|
|
123
|
-
stream: require.resolve('stream-browserify'),
|
|
124
|
-
zlib: require.resolve('browserify-zlib'),
|
|
125
|
-
assert: require.resolve('assert/'),
|
|
126
|
-
buffer: require.resolve('buffer/'),
|
|
127
|
-
url: require.resolve('url/'),
|
|
128
|
-
util: require.resolve('util/'),
|
|
129
|
-
process: 'process/browser.js'
|
|
130
|
-
}
|
|
121
|
+
{
|
|
122
|
+
test: /\.(woff(2)?|ttf|jpg|png|eot|gif|svg)(\?v=\d+\.\d+\.\d+)?$/,
|
|
123
|
+
type: 'asset/resource',
|
|
124
|
+
generator: {
|
|
125
|
+
filename: 'fonts/[name][ext]',
|
|
126
|
+
},
|
|
131
127
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
128
|
+
{
|
|
129
|
+
test: /\.mjs$/,
|
|
130
|
+
include: /node_modules/,
|
|
131
|
+
type: 'javascript/auto',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
resolve: {
|
|
136
|
+
extensions: ['.ts', '.tsx', '.mjs', '.js', '.scss'],
|
|
137
|
+
alias: {
|
|
138
|
+
...(bundlePfModules ? {} : searchIgnoredStyles(rootFolder)),
|
|
139
|
+
},
|
|
140
|
+
fallback: {
|
|
141
|
+
path: require.resolve('path-browserify'),
|
|
142
|
+
stream: require.resolve('stream-browserify'),
|
|
143
|
+
zlib: require.resolve('browserify-zlib'),
|
|
144
|
+
assert: require.resolve('assert/'),
|
|
145
|
+
buffer: require.resolve('buffer/'),
|
|
146
|
+
url: require.resolve('url/'),
|
|
147
|
+
util: require.resolve('util/'),
|
|
148
|
+
process: 'process/browser.js',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
devServer: {
|
|
152
|
+
static: {
|
|
153
|
+
directory: `${rootFolder || ''}/dist`,
|
|
154
|
+
},
|
|
155
|
+
port: devServerPort,
|
|
156
|
+
https: https || Boolean(useProxy),
|
|
157
|
+
host: '0.0.0.0', // This shares on local network. Needed for docker.host.internal
|
|
158
|
+
hot: false, // Use livereload instead of HMR which is spotty with federated modules
|
|
159
|
+
allowedHosts: 'all',
|
|
160
|
+
// https://github.com/bripkens/connect-history-api-fallback
|
|
161
|
+
historyApiFallback: {
|
|
162
|
+
// We should really implement the same logic as cloud-services-config
|
|
163
|
+
// and only redirect (/beta)?/bundle/app-name to /index.html
|
|
164
|
+
//
|
|
165
|
+
// Until then let known api calls fall through instead of returning /index.html
|
|
166
|
+
// for easier `fetch` debugging
|
|
167
|
+
rewrites: [
|
|
168
|
+
{ from: /^\/api/, to: '/404.html' },
|
|
169
|
+
{ from: /^(\/beta)?\/config/, to: '/404.html' },
|
|
170
|
+
],
|
|
171
|
+
verbose: Boolean(proxyVerbose),
|
|
172
|
+
},
|
|
173
|
+
devMiddleware: {
|
|
174
|
+
writeToDisk: true,
|
|
175
|
+
},
|
|
176
|
+
client,
|
|
177
|
+
...proxy({
|
|
178
|
+
useCloud,
|
|
179
|
+
env,
|
|
180
|
+
localChrome,
|
|
181
|
+
keycloakUri,
|
|
182
|
+
customProxy,
|
|
183
|
+
routes,
|
|
184
|
+
routesPath,
|
|
185
|
+
useProxy,
|
|
186
|
+
proxyURL,
|
|
187
|
+
standalone,
|
|
188
|
+
port: devServerPort,
|
|
189
|
+
reposDir,
|
|
190
|
+
appUrl,
|
|
191
|
+
publicPath,
|
|
192
|
+
proxyVerbose,
|
|
193
|
+
target,
|
|
194
|
+
registry,
|
|
195
|
+
onBeforeSetupMiddleware: ({ chromePath }) => {
|
|
196
|
+
if (useChromeTemplate && chromePath) {
|
|
197
|
+
copyTemplate(chromePath);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
179
203
|
};
|