arui-scripts 17.3.0 → 18.0.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/.turbo/turbo-lint.log +9 -11
- package/.turbo/turbo-test.log +5 -5
- package/CHANGELOG.md +16 -0
- package/build/configs/app-configs/calculate-dependent-config.d.ts +2 -2
- package/build/configs/app-configs/types.d.ts +5 -2
- package/build/configs/client-env-config/add-env-to-html-template.d.ts +1 -0
- package/build/configs/client-env-config/add-env-to-html-template.js +8 -0
- package/build/configs/client-env-config/client-config-plugin.d.ts +5 -0
- package/build/configs/client-env-config/client-config-plugin.js +26 -0
- package/build/configs/client-env-config/constants.d.ts +1 -0
- package/build/configs/client-env-config/constants.js +4 -0
- package/build/configs/client-env-config/get-env-config.d.ts +2 -0
- package/build/configs/client-env-config/get-env-config.js +29 -0
- package/build/configs/client-env-config/index.d.ts +3 -0
- package/build/configs/client-env-config/index.js +9 -0
- package/build/configs/dev-server.js +4 -2
- package/build/configs/modules.js +14 -6
- package/build/configs/webpack.client.js +5 -1
- package/build/templates/dockerfile.template.js +1 -1
- package/build/templates/html.template.d.ts +1 -1
- package/build/templates/html.template.js +3 -0
- package/build/templates/start.template.js +37 -3
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/docs/client-only.md +68 -2
- package/docs/modules.md +25 -3
- package/package.json +1 -1
package/.turbo/turbo-lint.log
CHANGED
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
|
|
107
107
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/app-configs/types.ts
|
|
108
108
|
90:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
109
|
-
|
|
109
|
+
113:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
110
110
|
|
|
111
111
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/app-configs/update-with-env.ts
|
|
112
112
|
12:9 warning Unexpected console statement no-console
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
3:8 warning Using exported name 'configs' as identifier for default export import/no-named-as-default
|
|
131
131
|
|
|
132
132
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/dev-server.ts
|
|
133
|
-
|
|
133
|
+
77:8 warning Prefer named exports import/no-default-export
|
|
134
134
|
|
|
135
135
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/jest/index.js
|
|
136
136
|
16:13 warning Unexpected console statement no-console
|
|
@@ -139,9 +139,8 @@
|
|
|
139
139
|
9:8 warning Using exported name 'configs' as identifier for default export import/no-named-as-default
|
|
140
140
|
19:5 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
|
|
141
141
|
19:5 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
117:5 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
|
|
142
|
+
35:5 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
|
|
143
|
+
126:54 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
145
144
|
|
|
146
145
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/postcss.ts
|
|
147
146
|
9:8 warning Prefer named exports import/no-default-export
|
|
@@ -208,9 +207,9 @@
|
|
|
208
207
|
16:8 warning Prefer named exports import/no-default-export
|
|
209
208
|
|
|
210
209
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.client.ts
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
168:47 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
211
|
+
187:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
212
|
+
444:60 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
214
213
|
|
|
215
214
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/configs/webpack.server.dev.ts
|
|
216
215
|
12:8 warning Prefer named exports import/no-default-export
|
|
@@ -240,12 +239,11 @@
|
|
|
240
239
|
36:8 warning Prefer named exports import/no-default-export
|
|
241
240
|
|
|
242
241
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/templates/start.template.ts
|
|
243
|
-
|
|
244
|
-
34:8 warning Prefer named exports import/no-default-export
|
|
242
|
+
70:8 warning Prefer named exports import/no-default-export
|
|
245
243
|
|
|
246
244
|
/home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/src/types.d.ts
|
|
247
245
|
4:12 warning Prefer named exports import/no-default-export
|
|
248
246
|
|
|
249
|
-
✖
|
|
247
|
+
✖ 133 problems (0 errors, 133 warnings)
|
|
250
248
|
0 errors and 3 warnings potentially fixable with the `--fix` option.
|
|
251
249
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (
|
|
2
|
-
PASS src/configs/util/__tests__/get-polyfills.tests.ts (
|
|
1
|
+
PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (35.531 s)
|
|
2
|
+
PASS src/configs/util/__tests__/get-polyfills.tests.ts (36.322 s)
|
|
3
3
|
PASS src/configs/util/__tests__/apply-overrides.tests.ts
|
|
4
|
-
PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
|
|
5
4
|
PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
|
|
5
|
+
PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
|
|
6
6
|
PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
|
|
7
7
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
8
8
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
9
9
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
10
10
|
Failed to load /home/runner/work/arui-scripts/arui-scripts/packages/arui-scripts/tsconfig.json: Missing baseUrl in compilerOptions
|
|
11
|
-
PASS src/configs/util/__tests__/find-plugin.tests.ts (
|
|
11
|
+
PASS src/configs/util/__tests__/find-plugin.tests.ts (46.485 s)
|
|
12
12
|
|
|
13
13
|
Test Suites: 7 passed, 7 total
|
|
14
14
|
Tests: 21 passed, 21 total
|
|
15
15
|
Snapshots: 0 total
|
|
16
|
-
Time:
|
|
16
|
+
Time: 48.068 s
|
|
17
17
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# [15.3.0](https://github.com/core-ds/arui-scripts/compare/v15.2.0...v15.3.0) (2023-06-30)
|
|
2
2
|
|
|
3
|
+
## 18.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#271](https://github.com/core-ds/arui-scripts/pull/271) [`ccff520`](https://github.com/core-ds/arui-scripts/commit/ccff52095274dc558574d08002d31cc3ecda7fa2) Thanks [@Lecklark](https://github.com/Lecklark)! - Исправление настройки output.publicPath в конфиге webpack для compat модулей
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#273](https://github.com/core-ds/arui-scripts/pull/273) [`b96804d`](https://github.com/core-ds/arui-scripts/commit/b96804dfb2e34dd7008c4a93e7c1103cbda9615c) Thanks [@VladislavNsk](https://github.com/VladislavNsk)! - Добавлена возможность задавать css префикс для MF модулей
|
|
12
|
+
|
|
13
|
+
## 17.4.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#266](https://github.com/core-ds/arui-scripts/pull/266) [`cf14904`](https://github.com/core-ds/arui-scripts/commit/cf14904e4a6412a193077ccc6e8e6216eda2e475) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Добавлен механизм работы с конфигурацией для client-only режима
|
|
18
|
+
|
|
3
19
|
## 17.3.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -64,10 +64,9 @@ export declare function calculateDependentConfig(config: AppConfigs): {
|
|
|
64
64
|
[libraryName: string]: string;
|
|
65
65
|
} | undefined;
|
|
66
66
|
exposes?: {
|
|
67
|
-
[moduleId: string]: {
|
|
67
|
+
[moduleId: string]: import("./types").ModuleConfigBase & {
|
|
68
68
|
entry: string;
|
|
69
69
|
externals?: Record<string, string> | undefined;
|
|
70
|
-
cssPrefix?: string | false | undefined;
|
|
71
70
|
};
|
|
72
71
|
} | undefined;
|
|
73
72
|
} | null;
|
|
@@ -75,6 +74,7 @@ export declare function calculateDependentConfig(config: AppConfigs): {
|
|
|
75
74
|
name?: string | undefined;
|
|
76
75
|
shared: any;
|
|
77
76
|
exposes?: Record<string, string> | undefined;
|
|
77
|
+
options?: import("./types").ModuleConfigBase | undefined;
|
|
78
78
|
} | null;
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
@@ -74,12 +74,15 @@ export type AppConfigs = {
|
|
|
74
74
|
name?: string;
|
|
75
75
|
shared: any;
|
|
76
76
|
exposes?: Record<string, string>;
|
|
77
|
+
options?: ModuleConfigBase;
|
|
77
78
|
} | null;
|
|
78
79
|
};
|
|
79
|
-
type
|
|
80
|
+
export type ModuleConfigBase = {
|
|
81
|
+
cssPrefix?: false | string;
|
|
82
|
+
};
|
|
83
|
+
type CompatModuleConfigBase = ModuleConfigBase & {
|
|
80
84
|
entry: string;
|
|
81
85
|
externals?: Record<string, string>;
|
|
82
|
-
cssPrefix?: false | string;
|
|
83
86
|
};
|
|
84
87
|
export type CompatModuleConfig = CompatModuleConfigBase & {
|
|
85
88
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addEnvToHtmlTemplate(html: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addEnvToHtmlTemplate = void 0;
|
|
4
|
+
const get_env_config_1 = require("./get-env-config");
|
|
5
|
+
function addEnvToHtmlTemplate(html) {
|
|
6
|
+
return html.replace('<%= envConfig %>', (0, get_env_config_1.getEnvConfigContent)());
|
|
7
|
+
}
|
|
8
|
+
exports.addEnvToHtmlTemplate = addEnvToHtmlTemplate;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientConfigPlugin = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const get_env_config_1 = require("./get-env-config");
|
|
6
|
+
class ClientConfigPlugin {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.cachedContent = null;
|
|
9
|
+
}
|
|
10
|
+
// eslint-disable-next-line class-methods-use-this
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
const pluginName = ClientConfigPlugin.name;
|
|
13
|
+
const { webpack } = compiler;
|
|
14
|
+
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
|
|
15
|
+
// Tapping to the assets processing pipeline on a specific stage.
|
|
16
|
+
compilation.hooks.processAssets.tap({
|
|
17
|
+
name: pluginName,
|
|
18
|
+
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
|
|
19
|
+
}, () => {
|
|
20
|
+
const content = (0, get_env_config_1.getEnvConfigContent)();
|
|
21
|
+
compilation.emitAsset(`../${constants_1.ENV_CONFIG_FILENAME}`, new webpack.sources.RawSource(content));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ClientConfigPlugin = ClientConfigPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ENV_CONFIG_FILENAME = "env-config.json";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getEnvConfigContent = exports.replaceTemplateVariables = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const app_configs_1 = require("../app-configs");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
function replaceTemplateVariables(template, variables) {
|
|
12
|
+
return template.replace(/\$\{(\w+)}/g, (match, varName) => variables[varName] || '');
|
|
13
|
+
}
|
|
14
|
+
exports.replaceTemplateVariables = replaceTemplateVariables;
|
|
15
|
+
let cachedEnvConfig = null;
|
|
16
|
+
function getEnvConfigContent() {
|
|
17
|
+
if (cachedEnvConfig) {
|
|
18
|
+
return cachedEnvConfig;
|
|
19
|
+
}
|
|
20
|
+
const configTemplate = path_1.default.join(app_configs_1.configs.cwd, constants_1.ENV_CONFIG_FILENAME);
|
|
21
|
+
if (!fs_1.default.existsSync(configTemplate)) {
|
|
22
|
+
cachedEnvConfig = '{}';
|
|
23
|
+
return cachedEnvConfig;
|
|
24
|
+
}
|
|
25
|
+
const templateContent = fs_1.default.readFileSync(configTemplate, 'utf8');
|
|
26
|
+
cachedEnvConfig = replaceTemplateVariables(templateContent, process.env);
|
|
27
|
+
return cachedEnvConfig;
|
|
28
|
+
}
|
|
29
|
+
exports.getEnvConfigContent = getEnvConfigContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addEnvToHtmlTemplate = exports.ClientConfigPlugin = exports.ENV_CONFIG_FILENAME = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
Object.defineProperty(exports, "ENV_CONFIG_FILENAME", { enumerable: true, get: function () { return constants_1.ENV_CONFIG_FILENAME; } });
|
|
6
|
+
var client_config_plugin_1 = require("./client-config-plugin");
|
|
7
|
+
Object.defineProperty(exports, "ClientConfigPlugin", { enumerable: true, get: function () { return client_config_plugin_1.ClientConfigPlugin; } });
|
|
8
|
+
var add_env_to_html_template_1 = require("./add-env-to-html-template");
|
|
9
|
+
Object.defineProperty(exports, "addEnvToHtmlTemplate", { enumerable: true, get: function () { return add_env_to_html_template_1.addEnvToHtmlTemplate; } });
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
8
8
|
const app_configs_1 = require("./app-configs");
|
|
9
|
+
const client_env_config_1 = require("./client-env-config");
|
|
9
10
|
const serverProxyConfig = {
|
|
10
11
|
'/**': Object.assign({ target: `http://127.0.0.1:${app_configs_1.configs.serverPort}`, bypass: (req) => {
|
|
11
12
|
var _a;
|
|
@@ -46,8 +47,9 @@ const devServerConfig = (0, apply_overrides_1.default)('devServer', {
|
|
|
46
47
|
},
|
|
47
48
|
devMiddleware: {
|
|
48
49
|
publicPath: `/${app_configs_1.configs.publicPath}`,
|
|
49
|
-
// dev-сервер не может корректно обработать файлы, которые лежат на уровень выше чем publicPath, а html,
|
|
50
|
-
|
|
50
|
+
// dev-сервер не может корректно обработать файлы, которые лежат на уровень выше чем publicPath, а html,
|
|
51
|
+
// создаваемый для client-only режима как раз такой. Так же работает и env-config.json
|
|
52
|
+
writeToDisk: (filename) => filename.endsWith('.html') || filename.endsWith(client_env_config_1.ENV_CONFIG_FILENAME),
|
|
51
53
|
},
|
|
52
54
|
static: [app_configs_1.configs.serverOutputPath],
|
|
53
55
|
proxy: Object.assign(app_configs_1.configs.proxy || {}, app_configs_1.configs.clientOnly ? {} : serverProxyConfig),
|
package/build/configs/modules.js
CHANGED
|
@@ -22,6 +22,10 @@ function patchMainWebpackConfigForModules(webpackConf) {
|
|
|
22
22
|
if (!app_configs_1.default.modules || !webpackConf.output || !webpackConf.plugins) {
|
|
23
23
|
return webpackConf;
|
|
24
24
|
}
|
|
25
|
+
const { cssPrefix } = app_configs_1.default.modules.options || {};
|
|
26
|
+
if (cssPrefix) {
|
|
27
|
+
addCssPrefix(webpackConf, cssPrefix);
|
|
28
|
+
}
|
|
25
29
|
webpackConf.output.publicPath = haveExposedDefaultModules()
|
|
26
30
|
? 'auto' // Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
|
|
27
31
|
: app_configs_1.default.publicPath;
|
|
@@ -66,6 +70,12 @@ function getExposeLoadersFormCompatModules() {
|
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
exports.getExposeLoadersFormCompatModules = getExposeLoadersFormCompatModules;
|
|
73
|
+
function addCssPrefix(webpackConf, cssPrefix) {
|
|
74
|
+
const cssRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.css$/');
|
|
75
|
+
const cssModulesRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.module\\.css$/');
|
|
76
|
+
addPrefixCssRule(cssRule, cssPrefix);
|
|
77
|
+
addPrefixCssRule(cssModulesRule, `:global(${cssPrefix})`);
|
|
78
|
+
}
|
|
69
79
|
function addPrefixCssRule(rule, prefix) {
|
|
70
80
|
if (!rule || !rule.use || !Array.isArray(rule.use)) {
|
|
71
81
|
return;
|
|
@@ -94,14 +104,12 @@ function patchWebpackConfigForCompat(module, webpackConf) {
|
|
|
94
104
|
webpackConf.externals = Object.assign(Object.assign({}, (webpackConf.externals || {})), (module.externals || {}));
|
|
95
105
|
// Название переменной вебпака, которую он будет использовать для загрузки чанков. Важно чтобы для разных модулей они отличались,
|
|
96
106
|
// иначе несколько модулей из одного приложения будут конфликтовать между собой
|
|
97
|
-
|
|
107
|
+
const uniqueName = module.name;
|
|
108
|
+
// Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать publicPath = auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
|
|
109
|
+
webpackConf.output = Object.assign(Object.assign({}, webpackConf.output), { publicPath: 'auto', uniqueName });
|
|
98
110
|
const cssPrefix = getCssPrefixForModule(module);
|
|
99
111
|
if (cssPrefix) {
|
|
100
|
-
|
|
101
|
-
const cssRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.css$/');
|
|
102
|
-
const cssModulesRule = (0, find_loader_1.findLoader)(webpackConf, '/\\.module\\.css$/');
|
|
103
|
-
addPrefixCssRule(cssRule, cssPrefix);
|
|
104
|
-
addPrefixCssRule(cssModulesRule, `:global(${cssPrefix})`);
|
|
112
|
+
addCssPrefix(webpackConf, cssPrefix);
|
|
105
113
|
}
|
|
106
114
|
return webpackConf;
|
|
107
115
|
}
|
|
@@ -32,6 +32,7 @@ const get_webpack_cache_dependencies_1 = require("./util/get-webpack-cache-depen
|
|
|
32
32
|
const app_configs_1 = require("./app-configs");
|
|
33
33
|
const babel_client_1 = __importDefault(require("./babel-client"));
|
|
34
34
|
const babel_dependencies_1 = require("./babel-dependencies");
|
|
35
|
+
const client_env_config_1 = require("./client-env-config");
|
|
35
36
|
const modules_1 = require("./modules");
|
|
36
37
|
const postcss_1 = __importDefault(require("./postcss"));
|
|
37
38
|
const process_assets_plugin_output_1 = require("./process-assets-plugin-output");
|
|
@@ -414,9 +415,12 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
|
|
|
414
415
|
new arui_runtime_1.AruiRuntimePlugin(),
|
|
415
416
|
app_configs_1.configs.clientOnly &&
|
|
416
417
|
new html_webpack_plugin_1.default({
|
|
417
|
-
templateContent:
|
|
418
|
+
templateContent: mode === 'dev'
|
|
419
|
+
? (0, client_env_config_1.addEnvToHtmlTemplate)(html_template_1.htmlTemplate)
|
|
420
|
+
: html_template_1.htmlTemplate,
|
|
418
421
|
filename: '../index.html',
|
|
419
422
|
}),
|
|
423
|
+
mode === 'dev' && app_configs_1.configs.clientOnly && new client_env_config_1.ClientConfigPlugin(),
|
|
420
424
|
// production plugins:
|
|
421
425
|
mode === 'prod' && new webpack_manifest_plugin_1.WebpackManifestPlugin(),
|
|
422
426
|
mode === 'prod' &&
|
|
@@ -32,7 +32,7 @@ ADD $NGINX_CONF_LOCATION ${nginxConfTargetLocation}
|
|
|
32
32
|
${nginxNonRootPart}
|
|
33
33
|
|
|
34
34
|
${app_configs_1.configs.runFromNonRootUser ? `ADD --chown=nginx:nginx ${appPathToAdd} ${appTargetPath}` : `ADD ${appPathToAdd} ${appTargetPath}`}
|
|
35
|
-
|
|
35
|
+
${app_configs_1.configs.clientOnly ? 'COPY env-config.jso[n] /src/ # конструкция с [n] нужная чтобы копирование было опциональным. Если файла не будет - сборка не упадёт' : ''}
|
|
36
36
|
${app_configs_1.configs.clientOnly ? 'CMD ["nginx"]' : ''}
|
|
37
37
|
`;
|
|
38
38
|
exports.default = (0, apply_overrides_1.default)('Dockerfile', dockerfileTemplate);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const htmlTemplate = "<!doctype html>\n<html lang=\"ru\">\n <head>\n <meta charset=\"utf-8\" />\n <title>React-app</title>\n <link\n rel=\"shortcut icon\"\n href=\"data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23EF3124' /%3E%3C/svg%3E\"\n >\n </head>\n <body>\n <div id=\"react-app\"></div>\n </body>\n</html>";
|
|
1
|
+
export declare const htmlTemplate = "<!doctype html>\n<html lang=\"ru\">\n <head>\n <meta charset=\"utf-8\" />\n <title>React-app</title>\n <link\n rel=\"shortcut icon\"\n href=\"data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23EF3124' /%3E%3C/svg%3E\"\n >\n </head>\n <body>\n <div id=\"react-app\"></div>\n <script id=\"env-settings\" type=\"application/json\">\n <%= envConfig %>\n </script>\n </body>\n</html>";
|
|
@@ -17,6 +17,9 @@ const template = `<!doctype html>
|
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="react-app"></div>
|
|
20
|
+
<script id="env-settings" type="application/json">
|
|
21
|
+
<%= envConfig %>
|
|
22
|
+
</script>
|
|
20
23
|
</body>
|
|
21
24
|
</html>`;
|
|
22
25
|
exports.htmlTemplate = (0, apply_overrides_1.default)('html', template);
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const app_configs_1 =
|
|
6
|
+
const app_configs_1 = require("../configs/app-configs");
|
|
7
|
+
const client_env_config_1 = require("../configs/client-env-config");
|
|
7
8
|
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
9
|
const startTemplate = `#!/bin/sh
|
|
9
10
|
|
|
@@ -32,6 +33,39 @@ node_memory_limit="$(($max_total_memory / 1024 / 1024 - 100))"
|
|
|
32
33
|
nginx &
|
|
33
34
|
|
|
34
35
|
# Start nodejs process
|
|
35
|
-
node --max-old-space-size="$node_memory_limit" ./${app_configs_1.
|
|
36
|
+
node --max-old-space-size="$node_memory_limit" ./${app_configs_1.configs.buildPath}/${app_configs_1.configs.serverOutput}
|
|
36
37
|
`;
|
|
37
|
-
|
|
38
|
+
const envConfigTargetPath = `/src/${app_configs_1.configs.buildPath}/${client_env_config_1.ENV_CONFIG_FILENAME}`;
|
|
39
|
+
const envConfigPath = `/src/${client_env_config_1.ENV_CONFIG_FILENAME}`;
|
|
40
|
+
const htmlPath = `/src/${app_configs_1.configs.buildPath}/index.html`;
|
|
41
|
+
const clientOnlyStartTemplate = `#!/bin/sh
|
|
42
|
+
|
|
43
|
+
# Мы подставляем значения из env в env-config.json если он есть, и кладем его в публичную папку.
|
|
44
|
+
# Дополнительно подставляем контент полученного файла в index.html
|
|
45
|
+
# Так как контент env-config может быть многострочным - дополнительно обрабатываем его через awk.
|
|
46
|
+
if [ -f ${envConfigPath} ]; then
|
|
47
|
+
cat ${envConfigPath} \\
|
|
48
|
+
| envsubst \\
|
|
49
|
+
> ${envConfigTargetPath}
|
|
50
|
+
|
|
51
|
+
# Define the placeholder and the file paths
|
|
52
|
+
PLACEHOLDER='<%= envConfig %>'
|
|
53
|
+
SETTINGS_FILE='${envConfigTargetPath}'
|
|
54
|
+
TARGET_FILE='${htmlPath}'
|
|
55
|
+
|
|
56
|
+
# Escape the placeholder for sed usage
|
|
57
|
+
ESCAPED_PLACEHOLDER=$(echo "$PLACEHOLDER" | sed 's/[\\/&]/\\\\&/g')
|
|
58
|
+
|
|
59
|
+
# Read the content of the settings and prepare it for substitution
|
|
60
|
+
SETTINGS_CONTENT=$(awk '{printf "%s\\\\n", $0}' "$SETTINGS_FILE")
|
|
61
|
+
|
|
62
|
+
# Replace the placeholder in the target file with the content of settings
|
|
63
|
+
cat ${htmlPath} \\
|
|
64
|
+
| sed "s/$ESCAPED_PLACEHOLDER/$SETTINGS_CONTENT/" \\
|
|
65
|
+
> /tmp/index.html
|
|
66
|
+
|
|
67
|
+
mv /tmp/index.html ${htmlPath}
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
nginx`;
|
|
71
|
+
exports.default = (0, apply_overrides_1.default)('start.sh', app_configs_1.configs.clientOnly ? clientOnlyStartTemplate : startTemplate);
|