arui-scripts 0.0.0-next-20230725145300
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/.browserslistrc +5 -0
- package/.turbo/turbo-build.log +0 -0
- package/.turbo/turbo-test.log +91 -0
- package/CHANGELOG.md +1032 -0
- package/README.md +716 -0
- package/bin/build.sh +2 -0
- package/build/bin/index.d.ts +3 -0
- package/build/bin/index.js +21 -0
- package/build/commands/archive-build/index.d.ts +1 -0
- package/build/commands/archive-build/index.js +80 -0
- package/build/commands/build/build-wrapper.d.ts +8 -0
- package/build/commands/build/build-wrapper.js +41 -0
- package/build/commands/build/client.d.ts +1 -0
- package/build/commands/build/client.js +41 -0
- package/build/commands/build/index.d.ts +1 -0
- package/build/commands/build/index.js +10 -0
- package/build/commands/build/server.d.ts +1 -0
- package/build/commands/build/server.js +29 -0
- package/build/commands/bundle-analyze/index.d.ts +1 -0
- package/build/commands/bundle-analyze/index.js +36 -0
- package/build/commands/changelog/index.d.ts +5 -0
- package/build/commands/changelog/index.js +116 -0
- package/build/commands/docker-build/index.d.ts +1 -0
- package/build/commands/docker-build/index.js +70 -0
- package/build/commands/docker-build-compiled/index.d.ts +1 -0
- package/build/commands/docker-build-compiled/index.js +52 -0
- package/build/commands/ensure-yarn/index.d.ts +0 -0
- package/build/commands/ensure-yarn/index.js +8 -0
- package/build/commands/start/client.d.ts +1 -0
- package/build/commands/start/client.js +8 -0
- package/build/commands/start/index.d.ts +1 -0
- package/build/commands/start/index.js +8 -0
- package/build/commands/start/print-compiler-output.d.ts +1 -0
- package/build/commands/start/print-compiler-output.js +15 -0
- package/build/commands/start/server.d.ts +1 -0
- package/build/commands/start/server.js +8 -0
- package/build/commands/start-prod/client.d.ts +1 -0
- package/build/commands/start-prod/client.js +8 -0
- package/build/commands/start-prod/index.d.ts +1 -0
- package/build/commands/start-prod/index.js +8 -0
- package/build/commands/start-prod/server.d.ts +1 -0
- package/build/commands/start-prod/server.js +8 -0
- package/build/commands/test/index.d.ts +3 -0
- package/build/commands/test/index.js +17 -0
- package/build/commands/util/check-required-files.d.ts +2 -0
- package/build/commands/util/check-required-files.js +67 -0
- package/build/commands/util/client-assets-sizes.d.ts +26 -0
- package/build/commands/util/client-assets-sizes.js +88 -0
- package/build/commands/util/docker-build.d.ts +21 -0
- package/build/commands/util/docker-build.js +89 -0
- package/build/commands/util/exec.d.ts +2 -0
- package/build/commands/util/exec.js +18 -0
- package/build/commands/util/format-webpack-messages.d.ts +11 -0
- package/build/commands/util/format-webpack-messages.js +93 -0
- package/build/commands/util/make-tmp-dir.d.ts +6 -0
- package/build/commands/util/make-tmp-dir.js +29 -0
- package/build/commands/util/run-client-dev-server.d.ts +2 -0
- package/build/commands/util/run-client-dev-server.js +47 -0
- package/build/commands/util/run-compilers.d.ts +1 -0
- package/build/commands/util/run-compilers.js +31 -0
- package/build/commands/util/run-server-watch-compiler.d.ts +2 -0
- package/build/commands/util/run-server-watch-compiler.js +21 -0
- package/build/commands/util/yarn.d.ts +5 -0
- package/build/commands/util/yarn.js +53 -0
- package/build/configs/app-configs/calculate-dependent-config.d.ts +76 -0
- package/build/configs/app-configs/calculate-dependent-config.js +37 -0
- package/build/configs/app-configs/get-defaults.d.ts +3 -0
- package/build/configs/app-configs/get-defaults.js +127 -0
- package/build/configs/app-configs/index.d.ts +6 -0
- package/build/configs/app-configs/index.js +22 -0
- package/build/configs/app-configs/types.d.ts +108 -0
- package/build/configs/app-configs/types.js +2 -0
- package/build/configs/app-configs/update-with-config-file.d.ts +2 -0
- package/build/configs/app-configs/update-with-config-file.js +23 -0
- package/build/configs/app-configs/update-with-env.d.ts +2 -0
- package/build/configs/app-configs/update-with-env.js +20 -0
- package/build/configs/app-configs/update-with-package.d.ts +2 -0
- package/build/configs/app-configs/update-with-package.js +10 -0
- package/build/configs/app-configs/update-with-presets.d.ts +2 -0
- package/build/configs/app-configs/update-with-presets.js +26 -0
- package/build/configs/app-configs/validate-settings-keys.d.ts +4 -0
- package/build/configs/app-configs/validate-settings-keys.js +14 -0
- package/build/configs/babel-client.d.ts +34 -0
- package/build/configs/babel-client.js +65 -0
- package/build/configs/babel-dependencies.d.ts +14 -0
- package/build/configs/babel-dependencies.js +39 -0
- package/build/configs/babel-server.d.ts +27 -0
- package/build/configs/babel-server.js +47 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +2 -0
- package/build/configs/config-extras/minimizers/imagemin/imagemin.js +42 -0
- package/build/configs/config-extras/minimizers/imagemin/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/imagemin/index.js +17 -0
- package/build/configs/config-extras/minimizers/index.d.ts +1 -0
- package/build/configs/config-extras/minimizers/index.js +17 -0
- package/build/configs/dev-server.d.ts +2 -0
- package/build/configs/dev-server.js +48 -0
- package/build/configs/jest/babel-transform.d.ts +2 -0
- package/build/configs/jest/babel-transform.js +4 -0
- package/build/configs/jest/css-mock.d.ts +1 -0
- package/build/configs/jest/css-mock.js +2 -0
- package/build/configs/jest/file-transform.d.ts +3 -0
- package/build/configs/jest/file-transform.js +9 -0
- package/build/configs/jest/index.d.ts +50 -0
- package/build/configs/jest/index.js +47 -0
- package/build/configs/modules.d.ts +16 -0
- package/build/configs/modules.js +101 -0
- package/build/configs/mq.css +22 -0
- package/build/configs/postcss.config.d.ts +25 -0
- package/build/configs/postcss.config.js +62 -0
- package/build/configs/postcss.d.ts +2 -0
- package/build/configs/postcss.js +9 -0
- package/build/configs/process-assets-plugin-output.d.ts +2 -0
- package/build/configs/process-assets-plugin-output.js +46 -0
- package/build/configs/server-externals-exemptions.d.ts +1 -0
- package/build/configs/server-externals-exemptions.js +21 -0
- package/build/configs/stats-options.d.ts +3 -0
- package/build/configs/stats-options.js +49 -0
- package/build/configs/supporting-browsers.d.ts +2 -0
- package/build/configs/supporting-browsers.js +13 -0
- package/build/configs/util/apply-overrides.d.ts +56 -0
- package/build/configs/util/apply-overrides.js +47 -0
- package/build/configs/util/check-node-version.d.ts +2 -0
- package/build/configs/util/check-node-version.js +7 -0
- package/build/configs/util/find-loader.d.ts +2 -0
- package/build/configs/util/find-loader.js +23 -0
- package/build/configs/util/get-entry.d.ts +9 -0
- package/build/configs/util/get-entry.js +22 -0
- package/build/configs/util/get-polyfills.d.ts +3 -0
- package/build/configs/util/get-polyfills.js +27 -0
- package/build/configs/util/install-sourcemap-support.d.ts +1 -0
- package/build/configs/util/install-sourcemap-support.js +7 -0
- package/build/configs/util/node-assets-ignore.d.ts +0 -0
- package/build/configs/util/node-assets-ignore.js +31 -0
- package/build/configs/util/noop.d.ts +1 -0
- package/build/configs/util/noop.js +2 -0
- package/build/configs/util/register-ts-node.d.ts +0 -0
- package/build/configs/util/register-ts-node.js +17 -0
- package/build/configs/util/resolve.d.ts +12 -0
- package/build/configs/util/resolve.js +30 -0
- package/build/configs/webpack.client.d.ts +10 -0
- package/build/configs/webpack.client.dev.d.ts +2 -0
- package/build/configs/webpack.client.dev.js +9 -0
- package/build/configs/webpack.client.js +402 -0
- package/build/configs/webpack.client.prod.d.ts +2 -0
- package/build/configs/webpack.client.prod.js +9 -0
- package/build/configs/webpack.server.d.ts +2 -0
- package/build/configs/webpack.server.dev.d.ts +2 -0
- package/build/configs/webpack.server.dev.js +9 -0
- package/build/configs/webpack.server.js +229 -0
- package/build/configs/webpack.server.prod.d.ts +2 -0
- package/build/configs/webpack.server.prod.js +9 -0
- package/build/index.d.ts +5 -0
- package/build/index.js +9 -0
- package/build/plugins/reload-server-webpack-plugin.d.ts +9 -0
- package/build/plugins/reload-server-webpack-plugin.js +42 -0
- package/build/templates/dockerfile-compiled.template.d.ts +2 -0
- package/build/templates/dockerfile-compiled.template.js +47 -0
- package/build/templates/dockerfile.template.d.ts +2 -0
- package/build/templates/dockerfile.template.js +32 -0
- package/build/templates/nginx.conf.template.d.ts +2 -0
- package/build/templates/nginx.conf.template.js +34 -0
- package/build/templates/start.template.d.ts +2 -0
- package/build/templates/start.template.js +37 -0
- package/build/tsconfig-local.tsbuildinfo +1 -0
- package/docs/modules.md +572 -0
- package/jest-preset.js +22 -0
- package/package.json +172 -0
- package/release.config.js +21 -0
- package/tsconfig-local.json +16 -0
- package/tsconfig.json +71 -0
|
@@ -0,0 +1,229 @@
|
|
|
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.createServerConfig = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
10
|
+
const webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
|
|
11
|
+
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
12
|
+
const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
|
|
13
|
+
const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
|
|
14
|
+
const app_configs_1 = __importDefault(require("./app-configs"));
|
|
15
|
+
const babel_server_1 = __importDefault(require("./babel-server"));
|
|
16
|
+
const postcss_1 = __importDefault(require("./postcss"));
|
|
17
|
+
const get_entry_1 = __importDefault(require("./util/get-entry"));
|
|
18
|
+
const babel_dependencies_1 = require("./babel-dependencies");
|
|
19
|
+
const server_externals_exemptions_1 = require("./server-externals-exemptions");
|
|
20
|
+
const run_script_webpack_plugin_1 = require("run-script-webpack-plugin");
|
|
21
|
+
const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
|
|
22
|
+
const WatchMissingNodeModulesPlugin_1 = __importDefault(require("react-dev-utils/WatchMissingNodeModulesPlugin"));
|
|
23
|
+
const ReloadServerPlugin = require('../plugins/reload-server-webpack-plugin');
|
|
24
|
+
const assetsIgnoreBanner = fs_1.default.readFileSync(require.resolve('./util/node-assets-ignore'), 'utf8');
|
|
25
|
+
const sourceMapSupportBanner = fs_1.default.readFileSync(require.resolve('./util/install-sourcemap-support'), 'utf8');
|
|
26
|
+
// style files regexes
|
|
27
|
+
const cssRegex = /\.css$/;
|
|
28
|
+
const cssModuleRegex = /\.module\.css$/;
|
|
29
|
+
function getSingleEntry(entryPoint, mode) {
|
|
30
|
+
const prefix = (mode === 'dev' && app_configs_1.default.useServerHMR) ? [`${require.resolve('webpack/hot/poll')}?1000`] : [];
|
|
31
|
+
return [...prefix, ...entryPoint];
|
|
32
|
+
}
|
|
33
|
+
// This is a function that wil return webpack configuration to build a server
|
|
34
|
+
const createServerConfig = (mode) => ({
|
|
35
|
+
mode: mode === 'dev' ? 'development' : 'production',
|
|
36
|
+
// fail on first error in production mode
|
|
37
|
+
bail: mode === 'prod',
|
|
38
|
+
devtool: mode === 'dev' ? app_configs_1.default.devSourceMaps : 'source-map',
|
|
39
|
+
target: 'node',
|
|
40
|
+
node: {
|
|
41
|
+
__filename: true,
|
|
42
|
+
__dirname: true
|
|
43
|
+
},
|
|
44
|
+
entry: (0, get_entry_1.default)(app_configs_1.default.serverEntry, getSingleEntry, mode),
|
|
45
|
+
context: app_configs_1.default.cwd,
|
|
46
|
+
output: {
|
|
47
|
+
assetModuleFilename: 'static/media/[name].[hash:8][ext]',
|
|
48
|
+
// Add /* filename */ comments to generated require()s in the output.
|
|
49
|
+
pathinfo: true,
|
|
50
|
+
path: app_configs_1.default.serverOutputPath,
|
|
51
|
+
publicPath: app_configs_1.default.publicPath,
|
|
52
|
+
filename: app_configs_1.default.serverOutput,
|
|
53
|
+
chunkFilename: '[name].js',
|
|
54
|
+
// Point sourcemap entries to original disk location (format as URL on Windows)
|
|
55
|
+
devtoolModuleFilenameTemplate: (info) => path_1.default
|
|
56
|
+
.relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
|
|
57
|
+
.replace(/\\/g, '/'),
|
|
58
|
+
},
|
|
59
|
+
cache: mode === 'dev' ? {
|
|
60
|
+
type: 'filesystem',
|
|
61
|
+
name: 'server',
|
|
62
|
+
buildDependencies: {
|
|
63
|
+
config: [__filename],
|
|
64
|
+
},
|
|
65
|
+
} : false,
|
|
66
|
+
externalsPresets: { node: true },
|
|
67
|
+
externals: [(0, webpack_node_externals_1.default)({
|
|
68
|
+
allowlist: server_externals_exemptions_1.serverExternalsExemptions,
|
|
69
|
+
// we cannot determine node_modules location before arui-scripts installation, so just load
|
|
70
|
+
// dependencies list from package.json
|
|
71
|
+
modulesFromFile: true,
|
|
72
|
+
})],
|
|
73
|
+
optimization: {
|
|
74
|
+
minimize: false,
|
|
75
|
+
nodeEnv: mode === 'dev' ? false : 'production',
|
|
76
|
+
},
|
|
77
|
+
resolve: {
|
|
78
|
+
// This allows you to set a fallback for where Webpack should look for modules.
|
|
79
|
+
// We placed these paths second because we want `node_modules` to "win"
|
|
80
|
+
// if there are any conflicts. This matches Node resolution mechanism.
|
|
81
|
+
// https://github.com/facebookincubator/create-react-app/issues/253
|
|
82
|
+
modules: ['node_modules', app_configs_1.default.appNodeModules],
|
|
83
|
+
// These are the reasonable defaults supported by the Node ecosystem.
|
|
84
|
+
// We also include JSX as a common component filename extension to support
|
|
85
|
+
// some tools, although we do not recommend using it, see:
|
|
86
|
+
// https://github.com/facebookincubator/create-react-app/issues/290
|
|
87
|
+
// `web` extension prefixes have been added for better support
|
|
88
|
+
// for React Native Web.
|
|
89
|
+
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
|
|
90
|
+
plugins: ([
|
|
91
|
+
(app_configs_1.default.tsconfig && new tsconfig_paths_webpack_plugin_1.default({
|
|
92
|
+
configFile: app_configs_1.default.tsconfig,
|
|
93
|
+
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx']
|
|
94
|
+
}))
|
|
95
|
+
].filter(Boolean)),
|
|
96
|
+
},
|
|
97
|
+
module: {
|
|
98
|
+
// typescript interface will be removed from modules, and we will get an error on correct code
|
|
99
|
+
// see https://github.com/webpack/webpack/issues/7378
|
|
100
|
+
strictExportPresence: !app_configs_1.default.tsconfig,
|
|
101
|
+
rules: [
|
|
102
|
+
{
|
|
103
|
+
oneOf: ([
|
|
104
|
+
// Process JS with Babel.
|
|
105
|
+
{
|
|
106
|
+
test: app_configs_1.default.useTscLoader ? /\.(js|jsx|mjs)$/ : /\.(js|jsx|mjs|ts|tsx)$/,
|
|
107
|
+
include: app_configs_1.default.appSrc,
|
|
108
|
+
loader: require.resolve('babel-loader'),
|
|
109
|
+
options: Object.assign(Object.assign({}, babel_server_1.default), {
|
|
110
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
111
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
112
|
+
// directory for faster rebuilds.
|
|
113
|
+
cacheDirectory: mode === 'dev' }),
|
|
114
|
+
},
|
|
115
|
+
(app_configs_1.default.tsconfig && app_configs_1.default.useTscLoader) && {
|
|
116
|
+
test: /\.tsx?$/,
|
|
117
|
+
use: [
|
|
118
|
+
{
|
|
119
|
+
loader: require.resolve('babel-loader'),
|
|
120
|
+
options: Object.assign({
|
|
121
|
+
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
|
122
|
+
// It enables caching results in ./node_modules/.cache/babel-loader/
|
|
123
|
+
// directory for faster rebuilds.
|
|
124
|
+
cacheDirectory: mode === 'dev'
|
|
125
|
+
}, babel_server_1.default)
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
loader: require.resolve('ts-loader'),
|
|
129
|
+
options: {
|
|
130
|
+
onlyCompileBundledFiles: true,
|
|
131
|
+
transpileOnly: true,
|
|
132
|
+
happyPackMode: true,
|
|
133
|
+
configFile: app_configs_1.default.tsconfig
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
// Process any JS outside of the app with Babel.
|
|
139
|
+
// Unlike the application JS, we only compile the standard ES features.
|
|
140
|
+
{
|
|
141
|
+
test: /\.(js|mjs)$/,
|
|
142
|
+
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
|
143
|
+
loader: require.resolve('babel-loader'),
|
|
144
|
+
options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: mode === 'dev', cacheCompression: false }),
|
|
145
|
+
},
|
|
146
|
+
// replace css imports with empty files
|
|
147
|
+
{
|
|
148
|
+
test: cssRegex,
|
|
149
|
+
exclude: cssModuleRegex,
|
|
150
|
+
loader: require.resolve('null-loader')
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
test: cssModuleRegex,
|
|
154
|
+
use: [
|
|
155
|
+
{
|
|
156
|
+
loader: require.resolve('css-loader'),
|
|
157
|
+
options: {
|
|
158
|
+
modules: {
|
|
159
|
+
exportOnlyLocals: true,
|
|
160
|
+
getLocalIdent: getCSSModuleLocalIdent_1.default
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
loader: require.resolve('postcss-loader'),
|
|
166
|
+
options: {
|
|
167
|
+
postcssOptions: {
|
|
168
|
+
plugins: postcss_1.default,
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
|
|
176
|
+
type: 'asset/resource',
|
|
177
|
+
generator: {
|
|
178
|
+
outputPath: app_configs_1.default.publicPath,
|
|
179
|
+
publicPath: app_configs_1.default.publicPath,
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
].filter(Boolean)),
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
plugins: ([
|
|
187
|
+
new webpack_1.default.BannerPlugin({
|
|
188
|
+
banner: assetsIgnoreBanner,
|
|
189
|
+
raw: true,
|
|
190
|
+
entryOnly: false
|
|
191
|
+
}),
|
|
192
|
+
app_configs_1.default.installServerSourceMaps && new webpack_1.default.BannerPlugin({
|
|
193
|
+
banner: sourceMapSupportBanner,
|
|
194
|
+
raw: true,
|
|
195
|
+
entryOnly: false
|
|
196
|
+
}),
|
|
197
|
+
app_configs_1.default.tsconfig !== null && new fork_ts_checker_webpack_plugin_1.default(),
|
|
198
|
+
// dev plugins:
|
|
199
|
+
mode === 'dev' && (app_configs_1.default.useServerHMR
|
|
200
|
+
? new run_script_webpack_plugin_1.RunScriptWebpackPlugin({
|
|
201
|
+
name: app_configs_1.default.serverOutput
|
|
202
|
+
})
|
|
203
|
+
: new ReloadServerPlugin({ script: path_1.default.join(app_configs_1.default.serverOutputPath, app_configs_1.default.serverOutput) })),
|
|
204
|
+
mode === 'dev' && new webpack_1.default.NoEmitOnErrorsPlugin(),
|
|
205
|
+
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
206
|
+
// a plugin that prints an error when you attempt to do this.
|
|
207
|
+
// See https://github.com/facebookincubator/create-react-app/issues/240
|
|
208
|
+
mode === 'dev' && new case_sensitive_paths_webpack_plugin_1.default(),
|
|
209
|
+
// If you require a missing module and then `npm install` it, you still have
|
|
210
|
+
// to restart the development server for Webpack to discover it. This plugin
|
|
211
|
+
// makes the discovery automatic so you don't have to restart.
|
|
212
|
+
// See https://github.com/facebookincubator/create-react-app/issues/186
|
|
213
|
+
mode === 'dev' && new WatchMissingNodeModulesPlugin_1.default(app_configs_1.default.appNodeModules),
|
|
214
|
+
mode === 'dev' && app_configs_1.default.useServerHMR && new webpack_1.default.HotModuleReplacementPlugin()
|
|
215
|
+
].filter(Boolean)),
|
|
216
|
+
experiments: {
|
|
217
|
+
backCompat: app_configs_1.default.webpack4Compatibility,
|
|
218
|
+
},
|
|
219
|
+
// Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
|
|
220
|
+
watchOptions: {
|
|
221
|
+
ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
|
|
222
|
+
aggregateTimeout: 100,
|
|
223
|
+
},
|
|
224
|
+
performance: {
|
|
225
|
+
// we don't really care about bundle size for server
|
|
226
|
+
hints: false,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
exports.createServerConfig = createServerConfig;
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
|
|
7
|
+
const webpack_server_1 = require("./webpack.server");
|
|
8
|
+
const config = (0, apply_overrides_1.default)(['webpack', 'webpackServer', 'webpackProd', 'webpackServerProd'], (0, webpack_server_1.createServerConfig)('prod'));
|
|
9
|
+
exports.default = config;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { OverrideFile } from './configs/util/apply-overrides';
|
|
2
|
+
export type { AppConfigs, PackageSettings } from './configs/app-configs/types';
|
|
3
|
+
export { prepareFilesForDocker } from './commands/util/docker-build';
|
|
4
|
+
export { getBuildParamsFromArgs } from './commands/util/docker-build';
|
|
5
|
+
export { getDockerBuildCommand } from './commands/util/docker-build';
|
package/build/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDockerBuildCommand = exports.getBuildParamsFromArgs = exports.prepareFilesForDocker = void 0;
|
|
4
|
+
var docker_build_1 = require("./commands/util/docker-build");
|
|
5
|
+
Object.defineProperty(exports, "prepareFilesForDocker", { enumerable: true, get: function () { return docker_build_1.prepareFilesForDocker; } });
|
|
6
|
+
var docker_build_2 = require("./commands/util/docker-build");
|
|
7
|
+
Object.defineProperty(exports, "getBuildParamsFromArgs", { enumerable: true, get: function () { return docker_build_2.getBuildParamsFromArgs; } });
|
|
8
|
+
var docker_build_3 = require("./commands/util/docker-build");
|
|
9
|
+
Object.defineProperty(exports, "getDockerBuildCommand", { enumerable: true, get: function () { return docker_build_3.getDockerBuildCommand; } });
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const cluster = require("cluster");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const defaultOptions = {
|
|
5
|
+
script: "server.js",
|
|
6
|
+
};
|
|
7
|
+
module.exports = class ReloadServerPlugin {
|
|
8
|
+
constructor({ script } = defaultOptions) {
|
|
9
|
+
this.done = null;
|
|
10
|
+
this.workers = [];
|
|
11
|
+
cluster.setupMaster({
|
|
12
|
+
exec: path.resolve(process.cwd(), script),
|
|
13
|
+
});
|
|
14
|
+
cluster.on("online", (worker) => {
|
|
15
|
+
this.workers.push(worker);
|
|
16
|
+
if (this.done) {
|
|
17
|
+
this.done();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
apply(compiler) {
|
|
22
|
+
const afterEmit = (compilation, callback) => {
|
|
23
|
+
this.done = callback;
|
|
24
|
+
this.workers.forEach((worker) => {
|
|
25
|
+
try {
|
|
26
|
+
process.kill(worker.process.pid, "SIGTERM");
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.warn(`Unable to kill process #${worker.process.pid}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
this.workers = [];
|
|
33
|
+
cluster.fork();
|
|
34
|
+
};
|
|
35
|
+
if (compiler.hooks) {
|
|
36
|
+
compiler.hooks.afterEmit.tapAsync('ReloadServerPlugin', afterEmit);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
compiler.plugin("after-emit", afterEmit);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
const app_configs_1 = __importDefault(require("../configs/app-configs"));
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
|
+
const yarn_1 = require("../commands/util/yarn");
|
|
9
|
+
const installProductionCommand = (0, yarn_1.getInstallProductionCommand)();
|
|
10
|
+
const yarnVersion = (0, yarn_1.getYarnVersion)();
|
|
11
|
+
// В зависимости от используемого мендежера зависимостей для их установки нужно копировать разный набор файлов
|
|
12
|
+
const filesRequiredToInstallDependencies = [
|
|
13
|
+
'package.json',
|
|
14
|
+
'yarn.lock',
|
|
15
|
+
yarnVersion === '2+' && '.yarnrc.yml',
|
|
16
|
+
yarnVersion === '2+' && '.yarn',
|
|
17
|
+
yarnVersion === 'unavailable' && 'package-lock.json',
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const dockerfileTemplate = `
|
|
20
|
+
FROM ${app_configs_1.default.baseDockerImage}
|
|
21
|
+
ARG START_SH_LOCATION
|
|
22
|
+
ARG NGINX_CONF_LOCATION
|
|
23
|
+
|
|
24
|
+
WORKDIR /src
|
|
25
|
+
|
|
26
|
+
# Полу-статичные файлы, могут легко кешироваться
|
|
27
|
+
ADD $START_SH_LOCATION /src/start.sh
|
|
28
|
+
ADD $NGINX_CONF_LOCATION /src/nginx.conf
|
|
29
|
+
|
|
30
|
+
# Зависимости. При некоторой удаче могут кешироваться и соответственно кешировать установку зависимостей
|
|
31
|
+
${filesRequiredToInstallDependencies.map((file) => `ADD --chown=nginx:nginx ${file} /src/${file}`).join('\n')}
|
|
32
|
+
|
|
33
|
+
RUN ${installProductionCommand} && \\
|
|
34
|
+
${yarnVersion === 'unavailable' ? 'npm cache clean --force' : 'yarn cache clean'}
|
|
35
|
+
|
|
36
|
+
ADD --chown=nginx:nginx . /src
|
|
37
|
+
|
|
38
|
+
# Создаем директории для nginx и выставляем правильные права
|
|
39
|
+
RUN mkdir -p /var/lib/nginx && \
|
|
40
|
+
chown -R nginx:nginx /var/lib/nginx && \
|
|
41
|
+
chown -R nginx:nginx /var/log/nginx && \
|
|
42
|
+
chown -R nginx:nginx /etc/nginx/conf.d
|
|
43
|
+
RUN touch /var/run/nginx.pid && \
|
|
44
|
+
chown -R nginx:nginx /var/run/nginx.pid
|
|
45
|
+
USER nginx
|
|
46
|
+
`;
|
|
47
|
+
exports.default = (0, apply_overrides_1.default)('DockerfileCompiled', dockerfileTemplate);
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
const app_configs_1 = __importDefault(require("../configs/app-configs"));
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
|
+
const nginxNonRootPart = app_configs_1.default.runFromNonRootUser ?
|
|
9
|
+
`RUN chown -R nginx:nginx /src && \\
|
|
10
|
+
mkdir -p /var/lib/nginx && \\
|
|
11
|
+
chown -R nginx:nginx /var/lib/nginx && \\
|
|
12
|
+
chown -R nginx:nginx /var/log/nginx && \\
|
|
13
|
+
chown -R nginx:nginx /etc/nginx/conf.d
|
|
14
|
+
|
|
15
|
+
RUN touch /var/run/nginx.pid && \\
|
|
16
|
+
chown -R nginx:nginx /var/run/nginx.pid
|
|
17
|
+
|
|
18
|
+
USER nginx`
|
|
19
|
+
: '';
|
|
20
|
+
const dockerfileTemplate = `
|
|
21
|
+
FROM ${app_configs_1.default.baseDockerImage}
|
|
22
|
+
ARG START_SH_LOCATION
|
|
23
|
+
ARG NGINX_CONF_LOCATION
|
|
24
|
+
|
|
25
|
+
WORKDIR /src
|
|
26
|
+
ADD $START_SH_LOCATION /src/start.sh
|
|
27
|
+
ADD $NGINX_CONF_LOCATION /src/nginx.conf
|
|
28
|
+
${nginxNonRootPart}
|
|
29
|
+
${app_configs_1.default.runFromNonRootUser ? 'ADD --chown=nginx:nginx . /src' : 'ADD . /src'}
|
|
30
|
+
|
|
31
|
+
`;
|
|
32
|
+
exports.default = (0, apply_overrides_1.default)('Dockerfile', dockerfileTemplate);
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
const app_configs_1 = __importDefault(require("../configs/app-configs"));
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
|
+
const nginxTemplate = `client_max_body_size 20m;
|
|
9
|
+
|
|
10
|
+
server {
|
|
11
|
+
listen ${app_configs_1.default.clientServerPort};
|
|
12
|
+
server_tokens off;
|
|
13
|
+
|
|
14
|
+
location / {
|
|
15
|
+
proxy_set_header Host $host;
|
|
16
|
+
proxy_pass http://127.0.0.1:${app_configs_1.default.serverPort};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
location /${app_configs_1.default.publicPath} {
|
|
20
|
+
expires max;
|
|
21
|
+
add_header Cache-Control public;
|
|
22
|
+
root ${app_configs_1.default.nginxRootPath}/${app_configs_1.default.buildPath};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
location ~ /${app_configs_1.default.publicPath}.*\\.js$ {
|
|
26
|
+
expires max;
|
|
27
|
+
add_header Cache-Control public;
|
|
28
|
+
root ${app_configs_1.default.nginxRootPath}/${app_configs_1.default.buildPath};
|
|
29
|
+
types {
|
|
30
|
+
text/javascript js;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}`;
|
|
34
|
+
exports.default = (0, apply_overrides_1.default)('nginx', nginxTemplate);
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
const app_configs_1 = __importDefault(require("../configs/app-configs"));
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
|
+
const startTemplate = `#!/bin/sh
|
|
9
|
+
|
|
10
|
+
# Подменяем env переменные в nginx конфиге перед стартом
|
|
11
|
+
# Сначала заменяем все слова, начинающиеся на $ но без \${} на ~~слово~~
|
|
12
|
+
# затем запускаем envsubst, после этого обратно заменяем ~~слово~~ на $слово.
|
|
13
|
+
# Это нужно для того, чтоб специальные переменные nginx не подменялись envsubst'ом на
|
|
14
|
+
# пустые строки. envsubst будет заменять только \${слово}.
|
|
15
|
+
cat ./nginx.conf \\
|
|
16
|
+
| sed 's/\\$\\([a-zA-Z0-9_-]\\{1,\\}\\)/~~\\1~~/g' \\
|
|
17
|
+
| envsubst \\
|
|
18
|
+
| sed 's/~~\\([a-zA-Z0-9_-]\\{1,\\}\\)~~/$\\1/g' \\
|
|
19
|
+
> /etc/nginx/conf.d/default.conf
|
|
20
|
+
|
|
21
|
+
# Достаем лимит памяти из cgroup, это то, как его докер задает.
|
|
22
|
+
if [[ -f /sys/fs/cgroup/cgroup.controllers ]]; then
|
|
23
|
+
max_total_memory=$(cat /sys/fs/cgroup/memory.max)
|
|
24
|
+
else
|
|
25
|
+
max_total_memory=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
|
|
26
|
+
fi
|
|
27
|
+
# Самой nodejs мы не можем отдать совсем всю память, операционная система+nginx все же требуют какого то количества.
|
|
28
|
+
# Поэтому мы вычитаем 100мб на нужды ос
|
|
29
|
+
node_memory_limit="$(($max_total_memory / 1024 / 1024 - 100))"
|
|
30
|
+
|
|
31
|
+
# Start the nginx process in background
|
|
32
|
+
nginx &
|
|
33
|
+
|
|
34
|
+
# Start nodejs process
|
|
35
|
+
node --max-old-space-size="$node_memory_limit" ./${app_configs_1.default.buildPath}/${app_configs_1.default.serverOutput}
|
|
36
|
+
`;
|
|
37
|
+
exports.default = (0, apply_overrides_1.default)('start.sh', startTemplate);
|