arui-scripts 14.0.0 → 14.1.1
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 +347 -341
- package/README.md +9 -6
- package/build/bin/index.js +0 -0
- package/build/commands/docker-build/index.js +2 -1
- package/build/commands/docker-build-compiled/index.js +2 -1
- package/build/commands/util/docker-build.d.ts +3 -2
- package/build/commands/util/docker-build.js +4 -1
- package/build/configs/app-configs/get-defaults.js +2 -0
- package/build/configs/app-configs/types.d.ts +1 -0
- package/build/configs/util/get-entry.d.ts +2 -1
- package/build/configs/util/get-entry.js +5 -4
- package/build/configs/webpack.client.d.ts +2 -0
- package/build/configs/webpack.client.dev.d.ts +2 -3
- package/build/configs/webpack.client.dev.js +3 -293
- package/build/configs/webpack.client.js +365 -0
- package/build/configs/webpack.client.prod.d.ts +1 -2
- package/build/configs/webpack.client.prod.js +2 -334
- package/build/configs/webpack.server.d.ts +2 -0
- package/build/configs/webpack.server.dev.d.ts +2 -3
- package/build/configs/webpack.server.dev.js +3 -228
- package/build/configs/webpack.server.js +239 -0
- package/build/configs/webpack.server.prod.d.ts +1 -2
- package/build/configs/webpack.server.prod.js +2 -192
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/package.json +7 -10
- package/release.config.js +1 -1
- package/build/commands/docker-build-fast/index.d.ts +0 -1
- package/build/commands/docker-build-fast/index.js +0 -90
- package/build/commands/start-vite/client.d.ts +0 -1
- package/build/commands/start-vite/client.js +0 -73
- package/build/commands/start-vite/index.d.ts +0 -1
- package/build/commands/start-vite/index.js +0 -25
- package/build/commands/util/localhost-certs.d.ts +0 -2
- package/build/commands/util/localhost-certs.js +0 -50
- package/build/commands/util/start-http2-proxy-server.d.ts +0 -7
- package/build/commands/util/start-http2-proxy-server.js +0 -40
- package/build/commands/util/vite-proxy-utils.d.ts +0 -64
- package/build/commands/util/vite-proxy-utils.js +0 -100
- package/build/configs/util/try-resolve.d.ts +0 -1
- package/build/configs/util/try-resolve.js +0 -12
- package/build/configs/vite.config.d.ts +0 -1
- package/build/configs/vite.config.js +0 -63
- package/build/configs/vite.html-template.d.ts +0 -1
- package/build/configs/vite.html-template.js +0 -16
- package/build/configs/webpack.dll.dev.d.ts +0 -3
- package/build/configs/webpack.dll.dev.js +0 -91
- package/build/templates/dockerfile-fast.template.d.ts +0 -2
- package/build/templates/dockerfile-fast.template.js +0 -32
package/README.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
ARUI-scripts
|
|
2
2
|
===
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Во многом пакет аналогичен `react-scripts` из `create-react-app`, разница заключается
|
|
7
|
-
в немного отличающихся настройках для `babel`, поддержки `ts` и возможности работы с серверным кодом.
|
|
4
|
+
Простой и гибкий инструмент для одновременной сборки клиентской и серверной части react-приложений.
|
|
8
5
|
|
|
9
6
|
Использование
|
|
10
7
|
===
|
|
@@ -78,7 +75,7 @@ npm install arui-scripts --save-dev
|
|
|
78
75
|
- `devSourceMaps` - какой вид source-map использовать в режиме разработки. По умолчанию `eval`. Эта настройка может сильно влиять на время сборки. Подробнее можно почитать [здесь](https://webpack.js.org/configuration/devtool/).
|
|
79
76
|
**Внимание**. При использовании любых source-map на основании `eval` webpack-dev-server будет модифицировать заголовок `Content-Security-Policy` (при наличии) и добавлять в него `unsafe-eval`. [Подробнее тут](#dev-csp).
|
|
80
77
|
- `useTscLoader` - использовать ts-loader вместо babel-loader для обработки ts файлов. У babel-loader есть [ряд ограничений](https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/). По умолчанию `false`.
|
|
81
|
-
- `componentsTheme` - путь к css файлу с темой для [core-components](https://
|
|
78
|
+
- `componentsTheme` - путь к css файлу с темой для [core-components](https://github.com/core-ds/core-components). Используется для настройки [postcss-custom-properties](https://github.com/postcss/postcss-custom-properties#importfrom).
|
|
82
79
|
- `keepCssVars` - отключает `postcss-custom-properties`, css переменные будут оставаться в бандле.
|
|
83
80
|
- `removeDevDependenciesDuringDockerBuild` - отключает удаление devDependencies из node_modules при сборке докер образа. Используется когда вам не нужно удалять devDependencies, т.к. в своём Dockerfile вы не переносите node_modules в докер-контейнер
|
|
84
81
|
|
|
@@ -294,7 +291,7 @@ docker
|
|
|
294
291
|
|
|
295
292
|
Команда `arui-scripts docker-build` запускает компиляцию продакшн версии и сборку докер образа.
|
|
296
293
|
|
|
297
|
-
Образ основан на [alpine-node-nginx](
|
|
294
|
+
Образ основан на [alpine-node-nginx](../alpine-node-nginx).
|
|
298
295
|
|
|
299
296
|
Имя контейнера определяется как `{configs.dockerRegistry}/{name}:{version}`. Переменные `name` и `version` по умолчанию берутся из package.json,
|
|
300
297
|
но вы так же можете переопределить их из командной строки, например
|
|
@@ -320,6 +317,12 @@ docker run -p 8080:8080 container-name:version ./start.sh
|
|
|
320
317
|
|
|
321
318
|
`Dockerfile` в корне проекта имеет приоритет над overrides.
|
|
322
319
|
|
|
320
|
+
Чтобы переопределить скрипт запуска, воспользуйтесь механизмом [overrides](#тонкая-настройка)
|
|
321
|
+
или создайте в корневой директории проекта `start.sh` файл содержащий необходимый набор инструкций.
|
|
322
|
+
Пример [start.sh](src/templates/start.template.ts).
|
|
323
|
+
|
|
324
|
+
`start.sh` в корне проекта имеет приоритет над overrides.
|
|
325
|
+
|
|
323
326
|
docker compiled
|
|
324
327
|
---
|
|
325
328
|
Команда `arui-scripts docker-build:compiled` во многом аналогична `docker-build`, но вместо сборки проекта использует уже скомпилированный в папку `.build` код.
|
package/build/bin/index.js
CHANGED
|
File without changes
|
|
@@ -30,8 +30,9 @@ const yarn_1 = require("../util/yarn");
|
|
|
30
30
|
pathToTempDir,
|
|
31
31
|
dockerfileTemplate: dockerfile_template_1.default,
|
|
32
32
|
nginxConfTemplate: nginx_conf_template_1.default,
|
|
33
|
-
|
|
33
|
+
startScriptTemplate: start_template_1.default,
|
|
34
34
|
allowLocalDockerfile: true,
|
|
35
|
+
allowLocalStartScript: true,
|
|
35
36
|
});
|
|
36
37
|
yield fs_extra_1.default.remove(app_configs_1.default.buildPath);
|
|
37
38
|
console.timeEnd('Setting up time');
|
|
@@ -28,8 +28,9 @@ const docker_build_1 = require("../util/docker-build");
|
|
|
28
28
|
pathToTempDir,
|
|
29
29
|
dockerfileTemplate: dockerfile_compiled_template_1.default,
|
|
30
30
|
nginxConfTemplate: nginx_conf_template_1.default,
|
|
31
|
-
|
|
31
|
+
startScriptTemplate: start_template_1.default,
|
|
32
32
|
allowLocalDockerfile: false,
|
|
33
|
+
allowLocalStartScript: false,
|
|
33
34
|
});
|
|
34
35
|
yield (0, exec_1.default)('echo "node_modules" >> .dockerignore');
|
|
35
36
|
yield (0, exec_1.default)(`docker build -f "./${tempDirName}/Dockerfile" \\
|
|
@@ -6,9 +6,10 @@ export declare function getBuildParamsFromArgs(): {
|
|
|
6
6
|
type PrepareFilesForDockerParams = {
|
|
7
7
|
dockerfileTemplate: string;
|
|
8
8
|
nginxConfTemplate: string;
|
|
9
|
-
|
|
9
|
+
startScriptTemplate: string;
|
|
10
10
|
pathToTempDir: string;
|
|
11
11
|
allowLocalDockerfile: boolean;
|
|
12
|
+
allowLocalStartScript: boolean;
|
|
12
13
|
};
|
|
13
|
-
export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate,
|
|
14
|
+
export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }: PrepareFilesForDockerParams): Promise<void>;
|
|
14
15
|
export {};
|
|
@@ -49,7 +49,7 @@ function getBuildParamsFromArgs() {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
exports.getBuildParamsFromArgs = getBuildParamsFromArgs;
|
|
52
|
-
function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate,
|
|
52
|
+
function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
yield fs_extra_1.default.emptyDir(pathToTempDir);
|
|
55
55
|
const nginxConf = app_configs_1.default.localNginxConf
|
|
@@ -58,6 +58,9 @@ function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScr
|
|
|
58
58
|
const dockerfile = app_configs_1.default.localDockerfile && allowLocalDockerfile
|
|
59
59
|
? yield fs_extra_1.default.readFile(app_configs_1.default.localDockerfile, 'utf8')
|
|
60
60
|
: dockerfileTemplate;
|
|
61
|
+
const startScript = app_configs_1.default.localStartScript && allowLocalStartScript
|
|
62
|
+
? yield fs_extra_1.default.readFile(app_configs_1.default.localStartScript, 'utf8')
|
|
63
|
+
: startScriptTemplate;
|
|
61
64
|
yield Promise.all([
|
|
62
65
|
fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'Dockerfile'), dockerfile, 'utf8'),
|
|
63
66
|
fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'nginx.conf'), nginxConf, 'utf8'),
|
|
@@ -21,6 +21,7 @@ function getDefaults() {
|
|
|
21
21
|
const overridesPath = (0, resolve_1.tryResolve)(path_1.default.join(CWD, 'arui-scripts.overrides'));
|
|
22
22
|
const nginxConfFilePath = path_1.default.join(CWD, 'nginx.conf');
|
|
23
23
|
const dockerfileFilePath = path_1.default.join(CWD, 'Dockerfile');
|
|
24
|
+
const startScriptFilePath = path_1.default.join(CWD, 'start.sh');
|
|
24
25
|
return {
|
|
25
26
|
appPackage,
|
|
26
27
|
name: appPackage.name,
|
|
@@ -50,6 +51,7 @@ function getDefaults() {
|
|
|
50
51
|
tsconfig: fs_1.default.existsSync(projectTsConfigPath) ? projectTsConfigPath : null,
|
|
51
52
|
localNginxConf: fs_1.default.existsSync(nginxConfFilePath) ? nginxConfFilePath : null,
|
|
52
53
|
localDockerfile: fs_1.default.existsSync(dockerfileFilePath) ? dockerfileFilePath : null,
|
|
54
|
+
localStartScript: fs_1.default.existsSync(startScriptFilePath) ? startScriptFilePath : null,
|
|
53
55
|
devSourceMaps: 'eval',
|
|
54
56
|
useTscLoader: false,
|
|
55
57
|
useServerHMR: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
|
|
3
3
|
* @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
|
|
4
|
+
* @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
|
|
4
5
|
* @returns {*}
|
|
5
6
|
*/
|
|
6
|
-
declare function getEntry(entryPoint: string | string[] | Record<string, string | string[]>, getSingleEntry: (entry: string[]) => string[]): string[] | Record<string, string | string[]>;
|
|
7
|
+
declare function getEntry<AdditionalArgs extends unknown[]>(entryPoint: string | string[] | Record<string, string | string[]>, getSingleEntry: (entry: string[], ...args: AdditionalArgs) => string[], ...args: AdditionalArgs): string[] | Record<string, string | string[]>;
|
|
7
8
|
export default getEntry;
|
|
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
|
|
5
5
|
* @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
|
|
6
|
+
* @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
|
|
6
7
|
* @returns {*}
|
|
7
8
|
*/
|
|
8
|
-
function getEntry(entryPoint, getSingleEntry) {
|
|
9
|
+
function getEntry(entryPoint, getSingleEntry, ...args) {
|
|
9
10
|
if (typeof entryPoint === 'string') {
|
|
10
|
-
return getSingleEntry([entryPoint]);
|
|
11
|
+
return getSingleEntry([entryPoint], ...args);
|
|
11
12
|
}
|
|
12
13
|
if (Array.isArray(entryPoint)) {
|
|
13
|
-
return getSingleEntry(entryPoint);
|
|
14
|
+
return getSingleEntry(entryPoint, ...args);
|
|
14
15
|
}
|
|
15
16
|
// client entry also can be an object, so we must add hot loader to each entry point
|
|
16
17
|
return Object.keys(entryPoint).reduce((result, entryPointName) => {
|
|
17
|
-
const entry = getEntry(entryPoint[entryPointName], getSingleEntry);
|
|
18
|
+
const entry = getEntry(entryPoint[entryPointName], getSingleEntry, ...args);
|
|
18
19
|
return Object.assign(Object.assign({}, result), { [entryPointName]: entry });
|
|
19
20
|
}, {});
|
|
20
21
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default webpackClientDev;
|
|
1
|
+
declare const config: import("webpack").Configuration;
|
|
2
|
+
export default config;
|
|
@@ -3,297 +3,7 @@ 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 path_1 = __importDefault(require("path"));
|
|
7
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
-
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
9
|
-
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
10
|
-
const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
|
|
11
|
-
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
12
|
-
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
13
|
-
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
|
14
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
15
|
-
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
16
|
-
const ReactRefreshTypeScript = require('react-refresh-typescript');
|
|
17
|
-
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
18
|
-
const babel_client_1 = __importDefault(require("./babel-client"));
|
|
19
|
-
const babel_dependencies_1 = require("./babel-dependencies");
|
|
20
|
-
const postcss_1 = __importDefault(require("./postcss"));
|
|
21
6
|
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const cssModuleRegex = /\.module\.css$/;
|
|
26
|
-
function getSingleEntry(clientEntry) {
|
|
27
|
-
return [
|
|
28
|
-
...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
|
|
29
|
-
require.resolve('webpack/hot/dev-server'),
|
|
30
|
-
// Finally, this is your app's code:
|
|
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.
|
|
35
|
-
].filter(Boolean);
|
|
36
|
-
}
|
|
37
|
-
// This is the development configuration.
|
|
38
|
-
// It is focused on developer experience and fast rebuilds.
|
|
39
|
-
// The production configuration is different and lives in a separate file.
|
|
40
|
-
const webpackClientDev = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], {
|
|
41
|
-
target: 'web',
|
|
42
|
-
mode: 'development',
|
|
43
|
-
devtool: app_configs_1.default.devSourceMaps,
|
|
44
|
-
// These are the "entry points" to our application.
|
|
45
|
-
// This means they will be the "root" imports that are included in JS bundle.
|
|
46
|
-
entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry),
|
|
47
|
-
context: app_configs_1.default.cwd,
|
|
48
|
-
output: {
|
|
49
|
-
// Add /* filename */ comments to generated require()s in the output.
|
|
50
|
-
pathinfo: true,
|
|
51
|
-
path: app_configs_1.default.clientOutputPath,
|
|
52
|
-
publicPath: app_configs_1.default.publicPath,
|
|
53
|
-
filename: '[name].js',
|
|
54
|
-
chunkFilename: '[name].js',
|
|
55
|
-
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
56
|
-
devtoolModuleFilenameTemplate: (info) => path_1.default
|
|
57
|
-
.relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
|
|
58
|
-
.replace(/\\/g, '/'),
|
|
59
|
-
},
|
|
60
|
-
resolve: {
|
|
61
|
-
// This allows you to set a fallback for where Webpack should look for modules.
|
|
62
|
-
// We placed these paths second because we want `node_modules` to "win"
|
|
63
|
-
// if there are any conflicts. This matches Node resolution mechanism.
|
|
64
|
-
// https://github.com/facebookincubator/create-react-app/issues/253
|
|
65
|
-
modules: ['node_modules', app_configs_1.default.appNodeModules],
|
|
66
|
-
// These are the reasonable defaults supported by the Node ecosystem.
|
|
67
|
-
// We also include JSX as a common component filename extension to support
|
|
68
|
-
// some tools, although we do not recommend using it, see:
|
|
69
|
-
// https://github.com/facebookincubator/create-react-app/issues/290
|
|
70
|
-
// `web` extension prefixes have been added for better support
|
|
71
|
-
// for React Native Web.
|
|
72
|
-
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
73
|
-
plugins: ([
|
|
74
|
-
(app_configs_1.default.tsconfig && new tsconfig_paths_webpack_plugin_1.default({
|
|
75
|
-
configFile: app_configs_1.default.tsconfig,
|
|
76
|
-
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx']
|
|
77
|
-
}))
|
|
78
|
-
].filter(Boolean)),
|
|
79
|
-
},
|
|
80
|
-
resolveLoader: {
|
|
81
|
-
plugins: [
|
|
82
|
-
PnpWebpackPlugin.moduleLoader(module),
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
cache: {
|
|
86
|
-
type: 'filesystem',
|
|
87
|
-
buildDependencies: {
|
|
88
|
-
config: [__filename],
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
module: {
|
|
92
|
-
// typescript interface will be removed from modules, and we will get an error on correct code
|
|
93
|
-
// see https://github.com/webpack/webpack/issues/7378
|
|
94
|
-
strictExportPresence: !app_configs_1.default.tsconfig,
|
|
95
|
-
rules: [
|
|
96
|
-
{
|
|
97
|
-
// "oneOf" will traverse all following loaders until one will
|
|
98
|
-
// match the requirements. When no loader matches it will fall
|
|
99
|
-
// back to the "file" loader at the end of the loader list.
|
|
100
|
-
oneOf: ([
|
|
101
|
-
{
|
|
102
|
-
test: [/\.svg$/],
|
|
103
|
-
loader: require.resolve('svg-url-loader'),
|
|
104
|
-
options: {
|
|
105
|
-
limit: 10000,
|
|
106
|
-
iesafe: true,
|
|
107
|
-
name: '[name].[hash:8].[ext]',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
// "url" loader works like "file" loader except that it embeds assets
|
|
111
|
-
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
112
|
-
// A missing `test` is equivalent to a match.
|
|
113
|
-
{
|
|
114
|
-
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
115
|
-
loader: require.resolve('url-loader'),
|
|
116
|
-
options: {
|
|
117
|
-
limit: 10000,
|
|
118
|
-
name: '[name].[hash:8].[ext]',
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
// Process JS with Babel.
|
|
122
|
-
{
|
|
123
|
-
test: app_configs_1.default.useTscLoader ? /\.(js|jsx|mjs|cjs)$/ : /\.(js|jsx|mjs|ts|tsx|cjs)$/,
|
|
124
|
-
include: app_configs_1.default.appSrc,
|
|
125
|
-
use: [
|
|
126
|
-
{
|
|
127
|
-
loader: require.resolve('babel-loader'),
|
|
128
|
-
options: Object.assign({
|
|
129
|
-
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
130
|
-
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
131
|
-
// directory for faster rebuilds.
|
|
132
|
-
cacheDirectory: true,
|
|
133
|
-
plugins: require.resolve('react-refresh/babel')
|
|
134
|
-
}, babel_client_1.default)
|
|
135
|
-
}
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
(app_configs_1.default.tsconfig && app_configs_1.default.useTscLoader) && {
|
|
139
|
-
test: /\.tsx?$/,
|
|
140
|
-
use: [
|
|
141
|
-
{
|
|
142
|
-
loader: require.resolve('babel-loader'),
|
|
143
|
-
options: Object.assign({
|
|
144
|
-
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
145
|
-
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
146
|
-
// directory for faster rebuilds.
|
|
147
|
-
cacheDirectory: true,
|
|
148
|
-
cacheCompression: false,
|
|
149
|
-
plugins: require.resolve('react-refresh/babel')
|
|
150
|
-
}, babel_client_1.default)
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
loader: require.resolve('ts-loader'),
|
|
154
|
-
options: {
|
|
155
|
-
getCustomTransformers: () => ({
|
|
156
|
-
before: [ReactRefreshTypeScript()],
|
|
157
|
-
}),
|
|
158
|
-
onlyCompileBundledFiles: true,
|
|
159
|
-
transpileOnly: true,
|
|
160
|
-
happyPackMode: true,
|
|
161
|
-
configFile: app_configs_1.default.tsconfig
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
},
|
|
166
|
-
// Process any JS outside of the app with Babel.
|
|
167
|
-
// Unlike the application JS, we only compile the standard ES features.
|
|
168
|
-
{
|
|
169
|
-
test: /\.(js|mjs)$/,
|
|
170
|
-
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
171
|
-
loader: require.resolve('babel-loader'),
|
|
172
|
-
options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: true, cacheCompression: false }),
|
|
173
|
-
},
|
|
174
|
-
// "postcss" loader applies autoprefixer to our CSS.
|
|
175
|
-
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
|
176
|
-
// "style" loader turns CSS into JS modules that inject <style> tags.
|
|
177
|
-
// In production, we use a plugin to extract that CSS to a file, but
|
|
178
|
-
// in development "style" loader enables hot editing of CSS.
|
|
179
|
-
{
|
|
180
|
-
test: cssRegex,
|
|
181
|
-
exclude: cssModuleRegex,
|
|
182
|
-
use: [
|
|
183
|
-
{
|
|
184
|
-
loader: MiniCssExtractPlugin.loader,
|
|
185
|
-
options: {
|
|
186
|
-
publicPath: './',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
loader: require.resolve('css-loader'),
|
|
191
|
-
options: {
|
|
192
|
-
importLoaders: 1,
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
loader: require.resolve('postcss-loader'),
|
|
197
|
-
options: {
|
|
198
|
-
// Necessary for external CSS imports to work
|
|
199
|
-
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
200
|
-
ident: 'postcss',
|
|
201
|
-
plugins: () => postcss_1.default,
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
test: cssModuleRegex,
|
|
208
|
-
use: [
|
|
209
|
-
{
|
|
210
|
-
loader: MiniCssExtractPlugin.loader,
|
|
211
|
-
options: {
|
|
212
|
-
publicPath: './',
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
loader: require.resolve('css-loader'),
|
|
217
|
-
options: {
|
|
218
|
-
importLoaders: 1,
|
|
219
|
-
modules: {
|
|
220
|
-
getLocalIdent: getCSSModuleLocalIdent_1.default
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
loader: require.resolve('postcss-loader'),
|
|
226
|
-
options: {
|
|
227
|
-
// Necessary for external CSS imports to work
|
|
228
|
-
// https://github.com/facebookincubator/create-react-app/issues/2677
|
|
229
|
-
ident: 'postcss',
|
|
230
|
-
plugins: () => postcss_1.default,
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
},
|
|
235
|
-
// "file" loader makes sure those assets get served by WebpackDevServer.
|
|
236
|
-
// When you `import` an asset, you get its (virtual) filename.
|
|
237
|
-
// In production, they would get copied to the `build` folder.
|
|
238
|
-
// This loader doesn't use a "test" so it will catch all modules
|
|
239
|
-
// that fall through the other loaders.
|
|
240
|
-
{
|
|
241
|
-
// Exclude `js` files to keep "css" loader working as it injects
|
|
242
|
-
// its runtime that would otherwise processed through "file" loader.
|
|
243
|
-
// Also exclude `html` and `json` extensions so they get processed
|
|
244
|
-
// by webpacks internal loaders.
|
|
245
|
-
exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
|
|
246
|
-
loader: require.resolve('file-loader'),
|
|
247
|
-
options: {
|
|
248
|
-
name: 'static/media/[name].[hash:8].[ext]',
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
].filter(Boolean)),
|
|
252
|
-
},
|
|
253
|
-
// ** STOP ** Are you adding a new loader?
|
|
254
|
-
// Make sure to add the new loader(s) before the "file" loader.
|
|
255
|
-
],
|
|
256
|
-
},
|
|
257
|
-
plugins: ([
|
|
258
|
-
new assets_webpack_plugin_1.default({ path: app_configs_1.default.serverOutputPath }),
|
|
259
|
-
new webpack_1.default.DefinePlugin({
|
|
260
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
|
|
261
|
-
// Tell Webpack to provide empty mocks for process.env.
|
|
262
|
-
'process.env': '{}'
|
|
263
|
-
}),
|
|
264
|
-
new ReactRefreshWebpackPlugin({
|
|
265
|
-
overlay: {
|
|
266
|
-
sockIntegration: 'whm',
|
|
267
|
-
},
|
|
268
|
-
}),
|
|
269
|
-
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
270
|
-
// a plugin that prints an error when you attempt to do this.
|
|
271
|
-
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
272
|
-
new case_sensitive_paths_webpack_plugin_1.default(),
|
|
273
|
-
app_configs_1.default.tsconfig !== null && new fork_ts_checker_webpack_plugin_1.default(),
|
|
274
|
-
new MiniCssExtractPlugin(),
|
|
275
|
-
].filter(Boolean)),
|
|
276
|
-
// Turn off performance hints during development because we don't do any
|
|
277
|
-
// splitting or minification in interest of speed. These warnings become
|
|
278
|
-
// cumbersome.
|
|
279
|
-
performance: {
|
|
280
|
-
hints: false,
|
|
281
|
-
},
|
|
282
|
-
optimization: {
|
|
283
|
-
minimize: false,
|
|
284
|
-
nodeEnv: false,
|
|
285
|
-
// Оптимизации времени билда, см https://webpack.js.org/guides/build-performance/
|
|
286
|
-
removeAvailableModules: false,
|
|
287
|
-
removeEmptyChunks: false,
|
|
288
|
-
splitChunks: false
|
|
289
|
-
},
|
|
290
|
-
experiments: {
|
|
291
|
-
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
292
|
-
},
|
|
293
|
-
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
294
|
-
watchOptions: {
|
|
295
|
-
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
296
|
-
aggregateTimeout: 100,
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
exports.default = webpackClientDev;
|
|
7
|
+
const webpack_client_1 = require("./webpack.client");
|
|
8
|
+
const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], (0, webpack_client_1.createClientWebpackConfig)('dev'));
|
|
9
|
+
exports.default = config;
|