@redhat-cloud-services/frontend-components-config 4.6.7 → 4.6.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 +4 -1
- package/package.json +2 -2
- package/src/config.js +1 -1
- package/src/plugins.js +8 -2
- package/src/plugins.test.js +27 -7
package/README.md
CHANGED
|
@@ -118,6 +118,9 @@ You can also easily run you application with a local build of Chrome by adding `
|
|
|
118
118
|
INSIGHTS_CHROME=/Users/rvsiansk/insights-project/insights-chrome/build/
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
**The path must end with a slash character / !!**
|
|
122
|
+
|
|
123
|
+
|
|
121
124
|
To check what the proxy is doing with your local chrome settings you can set `proxyVerbose: true`.
|
|
122
125
|
|
|
123
126
|
#### keycloakUri
|
|
@@ -489,4 +492,4 @@ const { config: webpackConfig, plugins } = config({
|
|
|
489
492
|
...
|
|
490
493
|
});
|
|
491
494
|
|
|
492
|
-
```
|
|
495
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-config",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.10",
|
|
4
4
|
"description": "Config plugins and settings for RedHat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"util": "^0.12.4",
|
|
54
54
|
"webpack": "^5.55.1",
|
|
55
55
|
"webpack-cli": "^4.8.0",
|
|
56
|
-
"webpack-dev-server": "4.
|
|
56
|
+
"webpack-dev-server": "4.8.1",
|
|
57
57
|
"write-file-webpack-plugin": "^4.5.1",
|
|
58
58
|
"yargs": "^17.2.1"
|
|
59
59
|
}
|
package/src/config.js
CHANGED
package/src/plugins.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { SourceMapDevToolPlugin } = require('webpack');
|
|
2
|
-
const { ProvidePlugin } = require('webpack');
|
|
2
|
+
const { ProvidePlugin, DefinePlugin } = require('webpack');
|
|
3
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
4
4
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
5
5
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
@@ -16,7 +16,8 @@ module.exports = ({
|
|
|
16
16
|
modules,
|
|
17
17
|
generateSourceMaps,
|
|
18
18
|
plugins,
|
|
19
|
-
useChromeTemplate =
|
|
19
|
+
useChromeTemplate = true,
|
|
20
|
+
definePlugin = {},
|
|
20
21
|
} = {}) => [
|
|
21
22
|
...(generateSourceMaps
|
|
22
23
|
? [
|
|
@@ -53,6 +54,11 @@ module.exports = ({
|
|
|
53
54
|
},
|
|
54
55
|
...(replacePlugin || []),
|
|
55
56
|
]),
|
|
57
|
+
new DefinePlugin({
|
|
58
|
+
// we have to wrap the appname string in another string because of how define plugin explodes strings
|
|
59
|
+
CRC_APP_NAME: JSON.stringify(insights?.appname),
|
|
60
|
+
...(definePlugin || {}),
|
|
61
|
+
}),
|
|
56
62
|
]),
|
|
57
63
|
new ProvidePlugin({
|
|
58
64
|
process: 'process/browser.js',
|
package/src/plugins.test.js
CHANGED
|
@@ -2,17 +2,18 @@ import plugins from './plugins';
|
|
|
2
2
|
|
|
3
3
|
const HTML_WEBPACK = 2;
|
|
4
4
|
const REPLACE = 3;
|
|
5
|
+
const DEFINE_PLUGIN = 4;
|
|
5
6
|
|
|
6
7
|
describe('plugins generations, no option', () => {
|
|
7
|
-
const enabledPlugins = plugins();
|
|
8
|
+
const enabledPlugins = plugins({ useChromeTemplate: false });
|
|
8
9
|
|
|
9
10
|
it('should generate plugins', () => {
|
|
10
|
-
expect(enabledPlugins.length).toBe(
|
|
11
|
+
expect(enabledPlugins.length).toBe(7);
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
it('should generate plugins with sourceMaps', () => {
|
|
14
|
-
const enabledPlugins = plugins({ generateSourceMaps: true });
|
|
15
|
-
expect(enabledPlugins.length).toBe(
|
|
15
|
+
const enabledPlugins = plugins({ generateSourceMaps: true, useChromeTemplate: false });
|
|
16
|
+
expect(enabledPlugins.length).toBe(8);
|
|
16
17
|
});
|
|
17
18
|
|
|
18
19
|
it('should generate correct template path for HtmlWebpackPlugin', () => {
|
|
@@ -21,7 +22,7 @@ describe('plugins generations, no option', () => {
|
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
describe('rootFolder', () => {
|
|
24
|
-
const enabledPlugins = plugins({ rootFolder: '/test/folder' });
|
|
25
|
+
const enabledPlugins = plugins({ rootFolder: '/test/folder', useChromeTemplate: false });
|
|
25
26
|
|
|
26
27
|
it('should generate correct template path for HtmlWebpackPlugin', () => {
|
|
27
28
|
expect(enabledPlugins[HTML_WEBPACK].userOptions.template).toBe('/test/folder/src/index.html');
|
|
@@ -29,7 +30,7 @@ describe('rootFolder', () => {
|
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
describe('appDeployment', () => {
|
|
32
|
-
const enabledPlugins = plugins({ appDeployment: '/test/folder' });
|
|
33
|
+
const enabledPlugins = plugins({ appDeployment: '/test/folder', useChromeTemplate: false });
|
|
33
34
|
|
|
34
35
|
it('should replace correct string', () => {
|
|
35
36
|
enabledPlugins[REPLACE].replace({ html: 'string @@env' }, (_, { html }) => expect(html).toBe('string /test/folder'));
|
|
@@ -37,12 +38,13 @@ describe('appDeployment', () => {
|
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
it('htmlPlugin should update', () => {
|
|
40
|
-
const enabledPlugins = plugins({ htmlPlugin: { title: 'myTitle' } });
|
|
41
|
+
const enabledPlugins = plugins({ htmlPlugin: { title: 'myTitle' }, useChromeTemplate: false });
|
|
41
42
|
expect(enabledPlugins[HTML_WEBPACK].userOptions.title).toBe('myTitle');
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
it('replacePlugin should update', () => {
|
|
45
46
|
const enabledPlugins = plugins({
|
|
47
|
+
useChromeTemplate: false,
|
|
46
48
|
replacePlugin: [
|
|
47
49
|
{
|
|
48
50
|
pattern: '@@another',
|
|
@@ -52,3 +54,21 @@ it('replacePlugin should update', () => {
|
|
|
52
54
|
});
|
|
53
55
|
enabledPlugins[REPLACE].replace({ html: '@@another string @@env' }, (_, { html }) => expect(html).toBe('test-string string '));
|
|
54
56
|
});
|
|
57
|
+
|
|
58
|
+
it('definePlugin should have default replace of CRC_APP_NAME', () => {
|
|
59
|
+
const enabledPlugins = plugins({
|
|
60
|
+
useChromeTemplate: false,
|
|
61
|
+
insights: { appname: 'test_app' },
|
|
62
|
+
});
|
|
63
|
+
expect(enabledPlugins[DEFINE_PLUGIN].definitions.CRC_APP_NAME).toBe('"test_app"');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('definePlugin should update', () => {
|
|
67
|
+
const enabledPlugins = plugins({
|
|
68
|
+
useChromeTemplate: false,
|
|
69
|
+
definePlugin: {
|
|
70
|
+
SOME_VAR: JSON.stringify('test_val'),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
expect(enabledPlugins[DEFINE_PLUGIN].definitions.SOME_VAR).toBe('"test_val"');
|
|
74
|
+
});
|