arui-scripts 13.3.1 → 13.4.0-feat-vite-dev-build.2
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/CHANGELOG.md +14 -0
- package/build/bin/index.js +1 -0
- package/build/commands/archive-build/index.js +3 -3
- package/build/commands/build/build-wrapper.d.ts +1 -1
- package/build/commands/build/build-wrapper.js +2 -2
- package/build/commands/build/client.js +4 -4
- package/build/commands/build/index.js +3 -3
- package/build/commands/build/server.js +2 -2
- package/build/commands/bundle-analyze/index.js +2 -2
- package/build/commands/docker-build/index.js +7 -7
- package/build/commands/docker-build-compiled/index.js +5 -5
- package/build/commands/start/client.js +3 -3
- package/build/commands/start/index.js +3 -3
- package/build/commands/start/server.js +2 -2
- package/build/commands/start-vite/client.d.ts +1 -0
- package/build/commands/start-vite/client.js +70 -0
- package/build/commands/start-vite/index.d.ts +1 -0
- package/build/commands/start-vite/index.js +25 -0
- package/build/commands/util/client-assets-sizes.d.ts +3 -3
- package/build/commands/util/client-assets-sizes.js +9 -9
- package/build/commands/util/docker-build.d.ts +1 -1
- package/build/commands/util/localhost-certs.d.ts +2 -0
- package/build/commands/util/localhost-certs.js +50 -0
- package/build/commands/util/start-http2-proxy-server.d.ts +7 -0
- package/build/commands/util/start-http2-proxy-server.js +40 -0
- package/build/commands/util/vite-proxy-utils.d.ts +64 -0
- package/build/commands/util/vite-proxy-utils.js +100 -0
- package/build/commands/util/yarn.d.ts +1 -1
- package/build/configs/app-configs/available-package-settings.d.ts +2 -2
- package/build/configs/app-configs/calculate-dependent-config.js +3 -3
- package/build/configs/app-configs/get-defaults.js +2 -1
- package/build/configs/app-configs/index.js +6 -6
- package/build/configs/app-configs/types.d.ts +2 -1
- package/build/configs/app-configs/update-with-config-file.js +3 -3
- package/build/configs/app-configs/update-with-env.js +2 -2
- package/build/configs/app-configs/update-with-package.js +2 -2
- package/build/configs/app-configs/update-with-presets.js +4 -4
- package/build/configs/babel-client.js +1 -1
- package/build/configs/babel-dependencies.js +1 -1
- package/build/configs/babel-server.js +1 -1
- package/build/configs/dev-server.js +1 -1
- package/build/configs/jest/file-transform.d.ts +1 -2
- package/build/configs/jest/index.d.ts +8 -8
- package/build/configs/postcss.config.d.ts +1 -1
- package/build/configs/postcss.js +1 -1
- package/build/configs/stats-options.js +1 -1
- package/build/configs/supporting-browsers.js +1 -1
- package/build/configs/util/apply-overrides.d.ts +6 -3
- package/build/configs/vite.config.d.ts +1 -0
- package/build/configs/vite.config.js +46 -0
- package/build/configs/vite.html-template.d.ts +1 -0
- package/build/configs/vite.html-template.js +16 -0
- package/build/configs/webpack.client.dev.js +7 -2
- package/build/configs/webpack.client.prod.js +5 -3
- package/build/configs/webpack.server.dev.js +3 -3
- package/build/configs/webpack.server.prod.js +3 -3
- package/build/index.js +1 -0
- package/build/templates/dockerfile-compiled.template.js +3 -3
- package/build/templates/dockerfile.template.js +1 -1
- package/build/templates/nginx.conf.template.js +1 -1
- package/build/templates/start.template.js +1 -1
- package/build/tsconfig-local.tsbuildinfo +1 -8816
- package/package.json +8 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { Request, Response } from 'express-serve-static-core';
|
|
3
|
+
import { HTMLElement } from 'node-html-parser';
|
|
4
|
+
export declare function processAssetsRequests(req: Request, res: Response): void;
|
|
5
|
+
export declare function fetchDataFromServer(req: Request): Promise<AxiosResponse<any, any>>;
|
|
6
|
+
export declare function updateHtmlResponse(fetchRes: AxiosResponse, templateScripts: HTMLElement[]): {
|
|
7
|
+
responseRoot: HTMLElement;
|
|
8
|
+
headers: {
|
|
9
|
+
[x: string]: string | undefined;
|
|
10
|
+
"set-cookie"?: string[] | undefined;
|
|
11
|
+
setContentType: (value: string | number | boolean | import("axios").AxiosHeaders | string[] | null, rewrite?: boolean | ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
12
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
13
|
+
}) => boolean) | undefined) => import("axios").AxiosHeaders;
|
|
14
|
+
getContentType: ((parser?: RegExp | undefined) => RegExpExecArray | null) | ((matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
15
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
16
|
+
}) => boolean) | undefined) => string | number | boolean | import("axios").AxiosHeaders | string[] | null);
|
|
17
|
+
hasContentType: (matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
18
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
19
|
+
}) => boolean) | undefined) => boolean;
|
|
20
|
+
setContentLength: (value: string | number | boolean | import("axios").AxiosHeaders | string[] | null, rewrite?: boolean | ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
21
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
22
|
+
}) => boolean) | undefined) => import("axios").AxiosHeaders;
|
|
23
|
+
getContentLength: ((parser?: RegExp | undefined) => RegExpExecArray | null) | ((matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
24
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
25
|
+
}) => boolean) | undefined) => string | number | boolean | import("axios").AxiosHeaders | string[] | null);
|
|
26
|
+
hasContentLength: (matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
27
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
28
|
+
}) => boolean) | undefined) => boolean;
|
|
29
|
+
setAccept: (value: string | number | boolean | import("axios").AxiosHeaders | string[] | null, rewrite?: boolean | ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
30
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
31
|
+
}) => boolean) | undefined) => import("axios").AxiosHeaders;
|
|
32
|
+
getAccept: ((parser?: RegExp | undefined) => RegExpExecArray | null) | ((matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
33
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
34
|
+
}) => boolean) | undefined) => string | number | boolean | import("axios").AxiosHeaders | string[] | null);
|
|
35
|
+
hasAccept: (matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
36
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
37
|
+
}) => boolean) | undefined) => boolean;
|
|
38
|
+
setUserAgent: (value: string | number | boolean | import("axios").AxiosHeaders | string[] | null, rewrite?: boolean | ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
39
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
40
|
+
}) => boolean) | undefined) => import("axios").AxiosHeaders;
|
|
41
|
+
getUserAgent: ((parser?: RegExp | undefined) => RegExpExecArray | null) | ((matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
42
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
43
|
+
}) => boolean) | undefined) => string | number | boolean | import("axios").AxiosHeaders | string[] | null);
|
|
44
|
+
hasUserAgent: (matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
45
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
46
|
+
}) => boolean) | undefined) => boolean;
|
|
47
|
+
setContentEncoding: (value: string | number | boolean | import("axios").AxiosHeaders | string[] | null, rewrite?: boolean | ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
48
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
49
|
+
}) => boolean) | undefined) => import("axios").AxiosHeaders;
|
|
50
|
+
getContentEncoding: ((parser?: RegExp | undefined) => RegExpExecArray | null) | ((matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
51
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
52
|
+
}) => boolean) | undefined) => string | number | boolean | import("axios").AxiosHeaders | string[] | null);
|
|
53
|
+
hasContentEncoding: (matcher?: ((this: import("axios").AxiosHeaders, value: string, name: string, headers: {
|
|
54
|
+
[x: string]: string | number | boolean | import("axios").AxiosHeaders | string[] | null;
|
|
55
|
+
}) => boolean) | undefined) => boolean;
|
|
56
|
+
} | {
|
|
57
|
+
[x: string]: string | undefined;
|
|
58
|
+
"set-cookie"?: string[] | undefined;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare function checkIfIsHtmlResponse(fetchRes: AxiosResponse): boolean | "" | undefined;
|
|
62
|
+
export declare function checkIfIsAssetsRequest(req: Request): boolean;
|
|
63
|
+
export declare function generateFakeWebpackAssets(): void;
|
|
64
|
+
export declare const reloadHtmlResponse = "<html>\n<script type=\"text/javascript\">setTimeout(() => {window.location.reload()}, 300)</script>\n<body>\n <h1>Getting things ready...</h1>\n</body>\n</html>";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.reloadHtmlResponse = exports.generateFakeWebpackAssets = exports.checkIfIsAssetsRequest = exports.checkIfIsHtmlResponse = exports.updateHtmlResponse = exports.fetchDataFromServer = exports.processAssetsRequests = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const fs_1 = __importDefault(require("fs"));
|
|
18
|
+
const app_configs_1 = __importDefault(require("../../configs/app-configs"));
|
|
19
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
// Обработчик запросов за статичными ассетами, сгенеренными серверным бандлом (favicon и тд)
|
|
22
|
+
function processAssetsRequests(req, res) {
|
|
23
|
+
const fileReadStream = fs_1.default.createReadStream(`${app_configs_1.default.serverOutputPath}${req.originalUrl}`);
|
|
24
|
+
fileReadStream.pipe(res);
|
|
25
|
+
}
|
|
26
|
+
exports.processAssetsRequests = processAssetsRequests;
|
|
27
|
+
// Получает данные из оригинального сервера, фактически проксируя текущий запрос
|
|
28
|
+
function fetchDataFromServer(req) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return (0, axios_1.default)(`http://localhost:${app_configs_1.default.serverPort}${req.originalUrl}`, {
|
|
31
|
+
headers: req.headers,
|
|
32
|
+
method: req.method,
|
|
33
|
+
data: req,
|
|
34
|
+
maxRedirects: 0,
|
|
35
|
+
responseType: 'text',
|
|
36
|
+
transformResponse: (res) => {
|
|
37
|
+
// нам не нужно парсить ответ, если вернулся json - оставляем его просто как строку
|
|
38
|
+
return res;
|
|
39
|
+
},
|
|
40
|
+
validateStatus: function (status) {
|
|
41
|
+
// все ответы считаем валидными, нам достаточно просто проксировать статус как есть
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.fetchDataFromServer = fetchDataFromServer;
|
|
48
|
+
// Вставляет в html, полученный от ssr корректные ссылки на скрипты для подключения js.
|
|
49
|
+
function updateHtmlResponse(fetchRes, templateScripts) {
|
|
50
|
+
const responseRoot = (0, node_html_parser_1.parse)(fetchRes.data);
|
|
51
|
+
const scripts = responseRoot.querySelectorAll('script');
|
|
52
|
+
let nonce = undefined;
|
|
53
|
+
scripts.forEach((appScript) => {
|
|
54
|
+
// Удаляем из ответа ссылку на фейковый js файл
|
|
55
|
+
if (appScript.getAttribute('src') === 'fake.js') {
|
|
56
|
+
appScript.parentNode.removeChild(appScript);
|
|
57
|
+
}
|
|
58
|
+
// Если приложение проставляет скриптам nonce тег - сохраняем его себе, чтобы поставить новым скриптам
|
|
59
|
+
if (appScript.getAttribute('nonce')) {
|
|
60
|
+
nonce = appScript.getAttribute('nonce');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const headElement = responseRoot.querySelector('head');
|
|
64
|
+
templateScripts.forEach((templateScript) => {
|
|
65
|
+
if (nonce) {
|
|
66
|
+
templateScript.setAttribute('nonce', nonce);
|
|
67
|
+
}
|
|
68
|
+
headElement === null || headElement === void 0 ? void 0 : headElement.appendChild(templateScript);
|
|
69
|
+
});
|
|
70
|
+
const headers = Object.assign({}, fetchRes.headers);
|
|
71
|
+
delete headers['content-length'];
|
|
72
|
+
return { responseRoot, headers };
|
|
73
|
+
}
|
|
74
|
+
exports.updateHtmlResponse = updateHtmlResponse;
|
|
75
|
+
// Проверят, является ли полученный ответ от сервера html
|
|
76
|
+
function checkIfIsHtmlResponse(fetchRes) {
|
|
77
|
+
return (fetchRes.status < 300 || fetchRes.status >= 400)
|
|
78
|
+
&& fetchRes.headers['content-type'] && fetchRes.headers['content-type'].indexOf('html') !== -1;
|
|
79
|
+
}
|
|
80
|
+
exports.checkIfIsHtmlResponse = checkIfIsHtmlResponse;
|
|
81
|
+
// Проверяет, является ли запрос - запросом за статичными ассетами
|
|
82
|
+
function checkIfIsAssetsRequest(req) {
|
|
83
|
+
return req.originalUrl.startsWith(`/${app_configs_1.default.assetsPath}/`);
|
|
84
|
+
}
|
|
85
|
+
exports.checkIfIsAssetsRequest = checkIfIsAssetsRequest;
|
|
86
|
+
// Создает фейковый файл с webpack-assets, который сможет использовать сервер приложения
|
|
87
|
+
function generateFakeWebpackAssets() {
|
|
88
|
+
fs_1.default.writeFileSync(path_1.default.join(app_configs_1.default.cwd, app_configs_1.default.buildPath, 'webpack-assets.json'), JSON.stringify({
|
|
89
|
+
"main": {
|
|
90
|
+
"js": ["fake.js"]
|
|
91
|
+
}
|
|
92
|
+
}), 'utf8');
|
|
93
|
+
}
|
|
94
|
+
exports.generateFakeWebpackAssets = generateFakeWebpackAssets;
|
|
95
|
+
exports.reloadHtmlResponse = `<html>
|
|
96
|
+
<script type="text/javascript">setTimeout(() => {window.location.reload()}, 300)</script>
|
|
97
|
+
<body>
|
|
98
|
+
<h1>Getting things ready...</h1>
|
|
99
|
+
</body>
|
|
100
|
+
</html>`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type YarnVersion = '1' | '2+' | 'unavailable';
|
|
2
2
|
export declare function getYarnVersion(): YarnVersion;
|
|
3
3
|
export declare function getPruningCommand(): string;
|
|
4
4
|
export declare function getInstallProductionCommand(): string;
|
|
@@ -3,6 +3,6 @@ import { AppConfigs } from './types';
|
|
|
3
3
|
* Эти ключи из конфига будут обновляться из package.json при их наличии
|
|
4
4
|
*/
|
|
5
5
|
export declare const availablePackageSettings: readonly ["dockerRegistry", "baseDockerImage", "serverEntry", "buildPath", "assetsPath", "additionalBuildPath", "nginxRootPath", "runFromNonRootUser", "archiveName", "serverOutput", "clientPolyfillsEntry", "clientEntry", "keepPropTypes", "devSourceMaps", "useTscLoader", "useServerHMR", "webpack4Compatibility", "clientServerPort", "serverPort", "debug", "statsOutputFilename", "componentsTheme", "keepCssVars", "removeDevDependenciesDuringDockerBuild"];
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
type ArrayElementType<ArrayType extends ReadonlyArray<unknown>> = ArrayType[number];
|
|
7
|
+
export type PackageSettings = Partial<Pick<AppConfigs, ArrayElementType<typeof availablePackageSettings>>>;
|
|
8
8
|
export {};
|
|
@@ -20,17 +20,17 @@ function calculateDependentConfig(config) {
|
|
|
20
20
|
// Поэтому мы читаем версию того babel/runtime, который установлен в проекте.
|
|
21
21
|
// Так же мы не можем использовать require для получения контента из babel/runtime/package.json,
|
|
22
22
|
// потому что webpack.cache будет ругаться на то, что мы пытаемся импортировать файлы НЕ из своего node_modules.
|
|
23
|
-
const pathToProjectBabelRuntime = resolve_1.resolveNodeModuleRelativeTo(config.cwd, '@babel/runtime/package.json');
|
|
23
|
+
const pathToProjectBabelRuntime = (0, resolve_1.resolveNodeModuleRelativeTo)(config.cwd, '@babel/runtime/package.json');
|
|
24
24
|
babelRuntimeVersion = JSON.parse(fs_1.default.readFileSync(pathToProjectBabelRuntime, 'utf8')).version;
|
|
25
25
|
}
|
|
26
26
|
catch (e) {
|
|
27
27
|
babelRuntimeVersion = require('@babel/runtime/package.json').version;
|
|
28
28
|
}
|
|
29
|
-
return lodash_merge_1.default(config, {
|
|
29
|
+
return (0, lodash_merge_1.default)(config, {
|
|
30
30
|
publicPath: `${config.assetsPath}/`,
|
|
31
31
|
serverOutputPath: path_1.default.resolve(config.cwd, config.buildPath),
|
|
32
32
|
clientOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.assetsPath),
|
|
33
|
-
clientPolyfillsEntry: get_polyfills_1.getPolyfills(config),
|
|
33
|
+
clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config),
|
|
34
34
|
statsOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.statsOutputFilename),
|
|
35
35
|
watchIgnorePath: ['node_modules', config.buildPath],
|
|
36
36
|
babelRuntimeVersion,
|
|
@@ -17,7 +17,7 @@ function getDefaults() {
|
|
|
17
17
|
const absoluteNodeModulesPath = path_1.default.resolve(CWD, 'node_modules');
|
|
18
18
|
const projectTsConfigPath = path_1.default.join(CWD, 'tsconfig.json');
|
|
19
19
|
const yarnLockFilePath = path_1.default.join(CWD, 'yarn.lock');
|
|
20
|
-
const overridesPath = resolve_1.tryResolve(path_1.default.join(CWD, 'arui-scripts.overrides'));
|
|
20
|
+
const overridesPath = (0, resolve_1.tryResolve)(path_1.default.join(CWD, 'arui-scripts.overrides'));
|
|
21
21
|
const nginxConfFilePath = path_1.default.join(CWD, 'nginx.conf');
|
|
22
22
|
const dockerfileFilePath = path_1.default.join(CWD, 'Dockerfile');
|
|
23
23
|
return {
|
|
@@ -56,6 +56,7 @@ function getDefaults() {
|
|
|
56
56
|
clientServerPort: 8080,
|
|
57
57
|
serverPort: 3000,
|
|
58
58
|
installServerSourceMaps: false,
|
|
59
|
+
viteDevPort: 23891,
|
|
59
60
|
debug: false,
|
|
60
61
|
overridesPath: overridesPath ? [overridesPath] : [],
|
|
61
62
|
statsOutputFilename: 'stats.json',
|
|
@@ -7,10 +7,10 @@ const update_with_package_1 = require("./update-with-package");
|
|
|
7
7
|
const update_with_presets_1 = require("./update-with-presets");
|
|
8
8
|
const calculate_dependent_config_1 = require("./calculate-dependent-config");
|
|
9
9
|
const update_with_config_file_1 = require("./update-with-config-file");
|
|
10
|
-
let config = get_defaults_1.getDefaults();
|
|
11
|
-
config = update_with_presets_1.updateWithPresets(config);
|
|
12
|
-
config = update_with_package_1.updateWithPackage(config);
|
|
13
|
-
config = update_with_config_file_1.updateWithConfigFile(config);
|
|
14
|
-
config = update_with_env_1.updateWithEnv(config);
|
|
15
|
-
config = calculate_dependent_config_1.calculateDependentConfig(config);
|
|
10
|
+
let config = (0, get_defaults_1.getDefaults)();
|
|
11
|
+
config = (0, update_with_presets_1.updateWithPresets)(config);
|
|
12
|
+
config = (0, update_with_package_1.updateWithPackage)(config);
|
|
13
|
+
config = (0, update_with_config_file_1.updateWithConfigFile)(config);
|
|
14
|
+
config = (0, update_with_env_1.updateWithEnv)(config);
|
|
15
|
+
config = (0, calculate_dependent_config_1.calculateDependentConfig)(config);
|
|
16
16
|
exports.default = config;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AppConfigs = {
|
|
2
2
|
appPackage: any;
|
|
3
3
|
name: string;
|
|
4
4
|
version: string;
|
|
@@ -30,6 +30,7 @@ export declare type AppConfigs = {
|
|
|
30
30
|
clientServerPort: number;
|
|
31
31
|
serverPort: number;
|
|
32
32
|
installServerSourceMaps: boolean;
|
|
33
|
+
viteDevPort: number;
|
|
33
34
|
debug: boolean;
|
|
34
35
|
overridesPath: string[];
|
|
35
36
|
statsOutputFilename: string;
|
|
@@ -10,15 +10,15 @@ const resolve_1 = require("../util/resolve");
|
|
|
10
10
|
const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
|
|
11
11
|
const available_package_settings_1 = require("./available-package-settings");
|
|
12
12
|
function updateWithConfigFile(config) {
|
|
13
|
-
const appConfigPath = resolve_1.tryResolve(path_1.default.join(config.cwd, '/arui-scripts.config'));
|
|
13
|
+
const appConfigPath = (0, resolve_1.tryResolve)(path_1.default.join(config.cwd, '/arui-scripts.config'));
|
|
14
14
|
if (appConfigPath) {
|
|
15
15
|
let appSettings = require(appConfigPath);
|
|
16
16
|
if (appSettings.__esModule) {
|
|
17
17
|
// ts-node импортирует esModules, из них надо вытягивать default именно так
|
|
18
18
|
appSettings = appSettings.default;
|
|
19
19
|
}
|
|
20
|
-
validate_settings_keys_1.default(available_package_settings_1.availablePackageSettings, appSettings);
|
|
21
|
-
config = lodash_merge_1.default(config, appSettings);
|
|
20
|
+
(0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, appSettings);
|
|
21
|
+
config = (0, lodash_merge_1.default)(config, appSettings);
|
|
22
22
|
}
|
|
23
23
|
return config;
|
|
24
24
|
}
|
|
@@ -14,8 +14,8 @@ function updateWithEnv(config) {
|
|
|
14
14
|
try {
|
|
15
15
|
console.warn('Используйте ARUI_SCRIPTS_CONFIG только для отладки');
|
|
16
16
|
const envSettings = JSON.parse(process.env.ARUI_SCRIPTS_CONFIG);
|
|
17
|
-
validate_settings_keys_1.default(available_package_settings_1.availablePackageSettings, envSettings);
|
|
18
|
-
return lodash_merge_1.default(config, envSettings);
|
|
17
|
+
(0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, envSettings);
|
|
18
|
+
return (0, lodash_merge_1.default)(config, envSettings);
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
21
|
console.error(e);
|
|
@@ -9,7 +9,7 @@ const validate_settings_keys_1 = __importDefault(require("./validate-settings-ke
|
|
|
9
9
|
const available_package_settings_1 = require("./available-package-settings");
|
|
10
10
|
function updateWithPackage(config) {
|
|
11
11
|
const packageSettings = config.appPackage.aruiScripts || {};
|
|
12
|
-
validate_settings_keys_1.default(available_package_settings_1.availablePackageSettings, packageSettings);
|
|
13
|
-
return lodash_merge_1.default(config, packageSettings);
|
|
12
|
+
(0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, packageSettings);
|
|
13
|
+
return (0, lodash_merge_1.default)(config, packageSettings);
|
|
14
14
|
}
|
|
15
15
|
exports.updateWithPackage = updateWithPackage;
|
|
@@ -13,16 +13,16 @@ function updateWithPresets(config) {
|
|
|
13
13
|
if (!packageSettings.presets) {
|
|
14
14
|
return config;
|
|
15
15
|
}
|
|
16
|
-
const presetsConfigPath = resolve_1.tryResolve(`${packageSettings.presets}/arui-scripts.config`, { paths: [config.cwd] });
|
|
17
|
-
const presetsOverridesPath = resolve_1.tryResolve(`${packageSettings.presets}/arui-scripts.overrides`, { paths: [config.cwd] });
|
|
16
|
+
const presetsConfigPath = (0, resolve_1.tryResolve)(`${packageSettings.presets}/arui-scripts.config`, { paths: [config.cwd] });
|
|
17
|
+
const presetsOverridesPath = (0, resolve_1.tryResolve)(`${packageSettings.presets}/arui-scripts.overrides`, { paths: [config.cwd] });
|
|
18
18
|
if (presetsConfigPath) {
|
|
19
19
|
let presetsSettings = require(presetsConfigPath);
|
|
20
20
|
if (presetsSettings.__esModule) {
|
|
21
21
|
// ts-node импортирует esModules, из них надо вытягивать default именно так
|
|
22
22
|
presetsSettings = presetsSettings.default;
|
|
23
23
|
}
|
|
24
|
-
validate_settings_keys_1.default(available_package_settings_1.availablePackageSettings, presetsSettings);
|
|
25
|
-
config = lodash_merge_1.default(config, presetsSettings);
|
|
24
|
+
(0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, presetsSettings);
|
|
25
|
+
config = (0, lodash_merge_1.default)(config, presetsSettings);
|
|
26
26
|
}
|
|
27
27
|
if (presetsOverridesPath) {
|
|
28
28
|
config.overridesPath.unshift(presetsOverridesPath);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const supporting_browsers_1 = __importDefault(require("./supporting-browsers"));
|
|
7
7
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
8
8
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
9
|
-
const babelClientConfig = apply_overrides_1.default(['babel', 'babelClient'], {
|
|
9
|
+
const babelClientConfig = (0, apply_overrides_1.default)(['babel', 'babelClient'], {
|
|
10
10
|
presets: [
|
|
11
11
|
[
|
|
12
12
|
require.resolve('@babel/preset-env'),
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.babelDependencies = void 0;
|
|
7
7
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
8
8
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
9
|
-
exports.babelDependencies = apply_overrides_1.default('babelDependencies', {
|
|
9
|
+
exports.babelDependencies = (0, apply_overrides_1.default)('babelDependencies', {
|
|
10
10
|
sourceType: 'unambiguous',
|
|
11
11
|
presets: [
|
|
12
12
|
[
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
7
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
8
|
-
const config = apply_overrides_1.default(['babel', 'babelServer'], {
|
|
8
|
+
const config = (0, apply_overrides_1.default)(['babel', 'babelServer'], {
|
|
9
9
|
presets: [
|
|
10
10
|
[
|
|
11
11
|
require.resolve('@babel/preset-env'),
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
8
8
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
9
|
-
const devServerConfig = apply_overrides_1.default('devServer', {
|
|
9
|
+
const devServerConfig = (0, apply_overrides_1.default)('devServer', {
|
|
10
10
|
port: app_configs_1.default.clientServerPort,
|
|
11
11
|
liveReload: false,
|
|
12
12
|
client: {
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function process(src: any, filename: any): string;
|
|
1
|
+
export function process(src: any, filename: any): string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export const testRegex: string;
|
|
2
|
+
export const moduleFileExtensions: string[];
|
|
3
|
+
export const collectCoverageFrom: string[];
|
|
4
|
+
export const transform: {
|
|
5
5
|
'^.+\\.jsx?$': string;
|
|
6
6
|
'^.+\\.tsx?$': string;
|
|
7
7
|
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export const moduleNameMapper: {
|
|
10
10
|
'\\.css$': string;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export const setupFiles: string[];
|
|
13
|
+
export const snapshotSerializers: string[];
|
|
14
|
+
export const globals: {
|
|
15
15
|
'ts-jest': {
|
|
16
16
|
tsconfig: string | null;
|
|
17
17
|
babelConfig: any;
|
package/build/configs/postcss.js
CHANGED
|
@@ -5,5 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
7
|
const postcss_config_1 = require("./postcss.config");
|
|
8
|
-
const postcssConfig = apply_overrides_1.default('postcss', postcss_config_1.createPostcssConfig(postcss_config_1.postcssPlugins, postcss_config_1.postcssPluginsOptions));
|
|
8
|
+
const postcssConfig = (0, apply_overrides_1.default)('postcss', (0, postcss_config_1.createPostcssConfig)(postcss_config_1.postcssPlugins, postcss_config_1.postcssPluginsOptions));
|
|
9
9
|
exports.default = postcssConfig;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
|
-
const statsOptions = apply_overrides_1.default('stats', {
|
|
7
|
+
const statsOptions = (0, apply_overrides_1.default)('stats', {
|
|
8
8
|
// Add asset Information
|
|
9
9
|
assets: false,
|
|
10
10
|
// Add information about cached (not built) modules
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
|
-
const supportingBrowsers = apply_overrides_1.default(['browsers', 'supportingBrowsers'], [
|
|
7
|
+
const supportingBrowsers = (0, apply_overrides_1.default)(['browsers', 'supportingBrowsers'], [
|
|
8
8
|
'last 2 versions',
|
|
9
9
|
'ie >= 10',
|
|
10
10
|
'Android >= 4',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Configuration as WebpackConfiguration, WebpackOptionsNormalized } from 'webpack';
|
|
2
2
|
import type { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
3
3
|
import { AppConfigs } from '../app-configs/types';
|
|
4
|
-
|
|
4
|
+
import { InlineConfig } from 'vite';
|
|
5
|
+
type Overrides = {
|
|
5
6
|
webpack: WebpackConfiguration;
|
|
6
7
|
webpackClient: WebpackConfiguration;
|
|
7
8
|
webpackDev: WebpackConfiguration;
|
|
@@ -13,6 +14,8 @@ declare type Overrides = {
|
|
|
13
14
|
webpackServerProd: WebpackConfiguration;
|
|
14
15
|
devServer: WebpackDevServerConfiguration;
|
|
15
16
|
stats: WebpackOptionsNormalized['stats'];
|
|
17
|
+
vite: InlineConfig;
|
|
18
|
+
viteHtml: string;
|
|
16
19
|
babel: any;
|
|
17
20
|
babelClient: any;
|
|
18
21
|
babelServer: any;
|
|
@@ -25,8 +28,8 @@ declare type Overrides = {
|
|
|
25
28
|
nginx: string;
|
|
26
29
|
'start.sh': string;
|
|
27
30
|
};
|
|
28
|
-
|
|
29
|
-
export
|
|
31
|
+
type OverrideFunction<K extends keyof Overrides> = (config: Overrides[K], appConfig: AppConfigs) => Overrides[K];
|
|
32
|
+
export type OverrideFile = {
|
|
30
33
|
[K in keyof Overrides]?: OverrideFunction<K>;
|
|
31
34
|
};
|
|
32
35
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const viteConfig: import("vite").InlineConfig;
|
|
@@ -0,0 +1,46 @@
|
|
|
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.viteConfig = void 0;
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
8
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
9
|
+
const plugin_react_1 = __importDefault(require("@vitejs/plugin-react"));
|
|
10
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
11
|
+
exports.viteConfig = (0, apply_overrides_1.default)('vite', {
|
|
12
|
+
server: {
|
|
13
|
+
middlewareMode: true,
|
|
14
|
+
hmr: {
|
|
15
|
+
protocol: 'ws',
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
appType: 'custom',
|
|
19
|
+
build: {
|
|
20
|
+
manifest: true,
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
input: app_configs_1.default.clientEntry,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
plugins: [
|
|
26
|
+
(0, plugin_react_1.default)({
|
|
27
|
+
jsxRuntime: 'classic',
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
resolve: {
|
|
31
|
+
alias: {
|
|
32
|
+
'#': app_configs_1.default.appSrc,
|
|
33
|
+
'@alfalab/core-components/vars': '@alfalab/core-components/vars/index.css',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
define: {
|
|
37
|
+
global: 'window',
|
|
38
|
+
'process.env': {},
|
|
39
|
+
module: {},
|
|
40
|
+
},
|
|
41
|
+
css: {
|
|
42
|
+
postcss: {
|
|
43
|
+
plugins: postcss_1.default
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const viteHtmlTemplate: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
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.viteHtmlTemplate = void 0;
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
8
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
9
|
+
exports.viteHtmlTemplate = (0, apply_overrides_1.default)('viteHtml', `<!DOCTYPE html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<script type="module" src="${app_configs_1.default.clientEntry}"></script>
|
|
15
|
+
</body>
|
|
16
|
+
</html>`);
|
|
@@ -29,18 +29,21 @@ function getSingleEntry(clientEntry) {
|
|
|
29
29
|
require.resolve('webpack/hot/dev-server'),
|
|
30
30
|
// Finally, this is your app's code:
|
|
31
31
|
...clientEntry,
|
|
32
|
+
// We include the app code last so that if there is a runtime error during
|
|
33
|
+
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
34
|
+
// changing JS code would still trigger a refresh.
|
|
32
35
|
].filter(Boolean);
|
|
33
36
|
}
|
|
34
37
|
// This is the development configuration.
|
|
35
38
|
// It is focused on developer experience and fast rebuilds.
|
|
36
39
|
// The production configuration is different and lives in a separate file.
|
|
37
|
-
const webpackClientDev = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], {
|
|
40
|
+
const webpackClientDev = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], {
|
|
38
41
|
target: 'web',
|
|
39
42
|
mode: 'development',
|
|
40
43
|
devtool: app_configs_1.default.devSourceMaps,
|
|
41
44
|
// These are the "entry points" to our application.
|
|
42
45
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
43
|
-
entry: get_entry_1.default(app_configs_1.default.clientEntry, getSingleEntry),
|
|
46
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry),
|
|
44
47
|
context: app_configs_1.default.cwd,
|
|
45
48
|
output: {
|
|
46
49
|
// Add /* filename */ comments to generated require()s in the output.
|
|
@@ -247,6 +250,8 @@ const webpackClientDev = apply_overrides_1.default(['webpack', 'webpackClient',
|
|
|
247
250
|
},
|
|
248
251
|
].filter(Boolean)),
|
|
249
252
|
},
|
|
253
|
+
// ** STOP ** Are you adding a new loader?
|
|
254
|
+
// Make sure to add the new loader(s) before the "file" loader.
|
|
250
255
|
],
|
|
251
256
|
},
|
|
252
257
|
plugins: ([
|
|
@@ -33,12 +33,12 @@ function getSingleEntry(entryPoint) {
|
|
|
33
33
|
].filter(Boolean);
|
|
34
34
|
}
|
|
35
35
|
// This is the production configuration.
|
|
36
|
-
const config = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackProd', 'webpackClientProd'], {
|
|
36
|
+
const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackProd', 'webpackClientProd'], {
|
|
37
37
|
mode: 'production',
|
|
38
38
|
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
|
|
39
39
|
devtool: 'cheap-module-source-map',
|
|
40
40
|
// In production, we only want to load the polyfills and the app code.
|
|
41
|
-
entry: get_entry_1.default(app_configs_1.default.clientEntry, getSingleEntry),
|
|
41
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry),
|
|
42
42
|
bail: true,
|
|
43
43
|
context: app_configs_1.default.cwd,
|
|
44
44
|
output: {
|
|
@@ -291,6 +291,8 @@ const config = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackPr
|
|
|
291
291
|
},
|
|
292
292
|
].filter(Boolean)),
|
|
293
293
|
},
|
|
294
|
+
// ** STOP ** Are you adding a new loader?
|
|
295
|
+
// Make sure to add the new loader(s) before the "file" loader.
|
|
294
296
|
],
|
|
295
297
|
},
|
|
296
298
|
plugins: ([
|
|
@@ -312,7 +314,7 @@ const config = apply_overrides_1.default(['webpack', 'webpackClient', 'webpackPr
|
|
|
312
314
|
threshold: 10240,
|
|
313
315
|
minRatio: 0.8
|
|
314
316
|
}),
|
|
315
|
-
check_node_version_1.default(10) && new compression_webpack_plugin_1.default({
|
|
317
|
+
(0, check_node_version_1.default)(10) && new compression_webpack_plugin_1.default({
|
|
316
318
|
filename: '[file].br',
|
|
317
319
|
algorithm: 'brotliCompress',
|
|
318
320
|
test: /\.(js|css|html|svg)$/,
|
|
@@ -39,7 +39,7 @@ const config = {
|
|
|
39
39
|
__filename: true,
|
|
40
40
|
__dirname: true
|
|
41
41
|
},
|
|
42
|
-
entry: get_entry_1.default(app_configs_1.default.serverEntry, getSingleEntry),
|
|
42
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.serverEntry, getSingleEntry),
|
|
43
43
|
context: app_configs_1.default.cwd,
|
|
44
44
|
output: {
|
|
45
45
|
// Add /* filename */ comments to generated require()s in the output.
|
|
@@ -61,7 +61,7 @@ const config = {
|
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
63
|
externalsPresets: { node: true },
|
|
64
|
-
externals: [webpack_node_externals_1.default({
|
|
64
|
+
externals: [(0, webpack_node_externals_1.default)({
|
|
65
65
|
allowlist: [
|
|
66
66
|
/^arui-feather/,
|
|
67
67
|
/^arui-ft-private/,
|
|
@@ -239,5 +239,5 @@ const config = {
|
|
|
239
239
|
ignored: /node_modules/,
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
|
-
const webpackServerDev = apply_overrides_1.default(['webpack', 'webpackServer', 'webpackDev', 'webpackServerDev'], config);
|
|
242
|
+
const webpackServerDev = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackDev', 'webpackServerDev'], config);
|
|
243
243
|
exports.default = webpackServerDev;
|