@redhat-cloud-services/frontend-components-config 4.5.6 → 4.5.10
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 +20 -0
- package/package.json +3 -3
- package/src/config.js +22 -4
- package/src/config.test.js +2 -2
- package/src/plugins.js +25 -14
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>`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-config",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.10",
|
|
4
4
|
"description": "Config plugins and settings for RedHat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
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.8",
|
|
24
24
|
"assert": "^2.0.0",
|
|
25
25
|
"babel-loader": "^8.2.2",
|
|
26
26
|
"browserify-zlib": "^0.2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"util": "^0.12.4",
|
|
49
49
|
"webpack": "^5.55.1",
|
|
50
50
|
"webpack-cli": "^4.8.0",
|
|
51
|
-
"webpack-dev-server": "
|
|
51
|
+
"webpack-dev-server": "4.3.1",
|
|
52
52
|
"write-file-webpack-plugin": "^4.5.1",
|
|
53
53
|
"yargs": "^17.2.1"
|
|
54
54
|
}
|
package/src/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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');
|
|
@@ -33,14 +34,26 @@ module.exports = ({
|
|
|
33
34
|
target,
|
|
34
35
|
registry,
|
|
35
36
|
client = {},
|
|
36
|
-
bundlePfModules = false
|
|
37
|
+
bundlePfModules = false,
|
|
38
|
+
useChromeTemplate = false
|
|
37
39
|
} = {}) => {
|
|
38
|
-
const filenameMask = `js/[name]${useFileHash ?
|
|
40
|
+
const filenameMask = `js/[name]${useFileHash ? `.${Date.now()}.[fullhash]` : ''}.js`;
|
|
39
41
|
if (betaEnv) {
|
|
40
42
|
env = `${betaEnv}-beta`;
|
|
41
43
|
console.warn('betaEnv is deprecated in favor of env');
|
|
42
44
|
}
|
|
43
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);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fs.writeFileSync(`${outputPath}/index.html`, template);
|
|
55
|
+
};
|
|
56
|
+
|
|
44
57
|
const devServerPort = typeof port === 'number' ? port : useProxy || standalone ? 1337 : 8002;
|
|
45
58
|
return {
|
|
46
59
|
mode: mode || (isProd ? 'production' : 'development'),
|
|
@@ -50,7 +63,7 @@ module.exports = ({
|
|
|
50
63
|
},
|
|
51
64
|
output: {
|
|
52
65
|
filename: filenameMask,
|
|
53
|
-
path:
|
|
66
|
+
path: outputPath,
|
|
54
67
|
publicPath,
|
|
55
68
|
chunkFilename: filenameMask
|
|
56
69
|
},
|
|
@@ -172,7 +185,12 @@ module.exports = ({
|
|
|
172
185
|
publicPath,
|
|
173
186
|
proxyVerbose,
|
|
174
187
|
target,
|
|
175
|
-
registry
|
|
188
|
+
registry,
|
|
189
|
+
onBeforeSetupMiddleware: ({ chromePath }) => {
|
|
190
|
+
if (useChromeTemplate && chromePath) {
|
|
191
|
+
copyTemplate(chromePath);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
176
194
|
})
|
|
177
195
|
}
|
|
178
196
|
};
|
package/src/config.test.js
CHANGED
|
@@ -36,10 +36,10 @@ describe('should create dummy config with no options', () => {
|
|
|
36
36
|
|
|
37
37
|
test('output', () => {
|
|
38
38
|
expect(output).toEqual({
|
|
39
|
-
filename:
|
|
39
|
+
filename: expect.stringMatching(/js\/\[name\]\.\d+\.\[fullhash\]\.js/),
|
|
40
40
|
path: '/dist',
|
|
41
41
|
publicPath: undefined,
|
|
42
|
-
chunkFilename:
|
|
42
|
+
chunkFilename: expect.stringMatching(/js\/\[name\]\.\d+\.\[fullhash\]\.js/)
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
package/src/plugins.js
CHANGED
|
@@ -15,7 +15,8 @@ module.exports = ({
|
|
|
15
15
|
insights,
|
|
16
16
|
modules,
|
|
17
17
|
generateSourceMaps,
|
|
18
|
-
plugins
|
|
18
|
+
plugins,
|
|
19
|
+
useChromeTemplate = false
|
|
19
20
|
} = {}) => [
|
|
20
21
|
...(generateSourceMaps
|
|
21
22
|
? [
|
|
@@ -31,20 +32,30 @@ module.exports = ({
|
|
|
31
32
|
filename: 'css/[name].[contenthash].css',
|
|
32
33
|
ignoreOrder: true
|
|
33
34
|
}),
|
|
34
|
-
new CleanWebpackPlugin({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
new CleanWebpackPlugin({
|
|
36
|
+
cleanStaleWebpackAssets: false,
|
|
37
|
+
cleanOnceBeforeBuildPatterns: useChromeTemplate ? [
|
|
38
|
+
'**/*',
|
|
39
|
+
'!index.html'
|
|
40
|
+
] : [
|
|
41
|
+
'**/*'
|
|
42
|
+
]
|
|
41
43
|
}),
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
...(useChromeTemplate ? [] : [
|
|
45
|
+
new HtmlWebpackPlugin({
|
|
46
|
+
title: 'My App',
|
|
47
|
+
filename: 'index.html',
|
|
48
|
+
template: `${rootFolder || ''}/src/index.html`,
|
|
49
|
+
inject: false,
|
|
50
|
+
...htmlPlugin || {}
|
|
51
|
+
}),
|
|
52
|
+
new HtmlReplaceWebpackPlugin([
|
|
53
|
+
{
|
|
54
|
+
pattern: '@@env',
|
|
55
|
+
replacement: appDeployment || ''
|
|
56
|
+
},
|
|
57
|
+
...replacePlugin || []
|
|
58
|
+
])
|
|
48
59
|
]),
|
|
49
60
|
new ProvidePlugin({
|
|
50
61
|
process: 'process/browser.js',
|