@omnific/react-scripts 0.1.0 → 0.1.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/dist/build-CoW3Nti_.js +195 -0
- package/dist/dev-D0bbZds7.js +298 -0
- package/dist/index.js +330 -22
- package/dist/main.d.ts +3 -3
- package/dist/main.js +1 -4
- package/dist/paths-DdPGCuT5.js +35 -0
- package/dist/scripts/build.js +2 -195
- package/dist/scripts/dev.js +2 -299
- package/package.json +13 -13
- package/dist/env-DxzdvROc.js +0 -22
- package/dist/main.cjs +0 -73
- package/dist/main.d.cts +0 -30
- package/dist/rspack.config-8gFQGJU3.js +0 -285
package/dist/scripts/dev.js
CHANGED
|
@@ -1,299 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { styleText } from "node:util";
|
|
4
|
-
import { exit } from "node:process";
|
|
5
|
-
import { rspack } from "@rspack/core";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
import { RspackDevServer } from "@rspack/dev-server";
|
|
8
|
-
import url from "node:url";
|
|
9
|
-
import prompts from "prompts";
|
|
10
|
-
import getPort from "get-port";
|
|
11
|
-
import os from "node:os";
|
|
12
|
-
//#region utils/address.ts
|
|
13
|
-
function getDefaultInterfaceName() {
|
|
14
|
-
let value = "eth";
|
|
15
|
-
const platform = os.platform();
|
|
16
|
-
if (platform === "darwin") value = "en";
|
|
17
|
-
else if (platform === "win32") value = void 0;
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
function matchName(actualFamily, expectedFamily) {
|
|
21
|
-
if (expectedFamily === "IPv4") return actualFamily === "IPv4" || actualFamily === 4;
|
|
22
|
-
if (expectedFamily === "IPv6") return actualFamily === "IPv6" || actualFamily === 6;
|
|
23
|
-
return actualFamily === expectedFamily;
|
|
24
|
-
}
|
|
25
|
-
function findAddressFromInterface(items, expectedFamily, ignoreLoAddress = false) {
|
|
26
|
-
let firstMatchItem;
|
|
27
|
-
for (const item of items) if (matchName(item.family, expectedFamily)) {
|
|
28
|
-
if (ignoreLoAddress && item.address.startsWith("127.")) continue;
|
|
29
|
-
if (expectedFamily === "IPv6") {
|
|
30
|
-
if (item.scopeid === 0) return item;
|
|
31
|
-
if (!firstMatchItem) firstMatchItem = item;
|
|
32
|
-
} else return item;
|
|
33
|
-
}
|
|
34
|
-
return firstMatchItem;
|
|
35
|
-
}
|
|
36
|
-
function getInterfaceAddress(family, name) {
|
|
37
|
-
const interfaces = os.networkInterfaces();
|
|
38
|
-
const noName = !name;
|
|
39
|
-
name = name || getDefaultInterfaceName();
|
|
40
|
-
family = family || "IPv4";
|
|
41
|
-
if (name) for (let index = -1; index < 8; index++) {
|
|
42
|
-
const items = interfaces[name + (index >= 0 ? index : "")];
|
|
43
|
-
if (items) {
|
|
44
|
-
const item = findAddressFromInterface(items, family);
|
|
45
|
-
if (item) return item;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (noName) for (const k in interfaces) {
|
|
49
|
-
const items = interfaces[k];
|
|
50
|
-
if (items) {
|
|
51
|
-
const item = findAddressFromInterface(items, family, true);
|
|
52
|
-
if (item) return item;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get current machine IPv4
|
|
58
|
-
*
|
|
59
|
-
* interfaceName: interface name, default is 'eth' on linux, 'en' on mac os.
|
|
60
|
-
*/
|
|
61
|
-
function ip(interfaceName) {
|
|
62
|
-
return getInterfaceAddress("IPv4", interfaceName)?.address;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region utils/is-root.ts
|
|
66
|
-
/**
|
|
67
|
-
* 检查进程是否以 root 用户身份运行
|
|
68
|
-
*/
|
|
69
|
-
function isRoot() {
|
|
70
|
-
return process.getuid && process.getuid() === 0;
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region utils/clear-console.ts
|
|
74
|
-
/**
|
|
75
|
-
* 清除控制台的信息
|
|
76
|
-
*/
|
|
77
|
-
function clearConsole() {
|
|
78
|
-
process.stdout.write(process.platform === "win32" ? "\x1B[2J\x1B[0f" : "\x1B[2J\x1B[3J\x1B[H");
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region utils/dev-server-utils.ts
|
|
82
|
-
const isInteractive$1 = process.stdout.isTTY;
|
|
83
|
-
function printInstructions(appName, urls) {
|
|
84
|
-
console.log();
|
|
85
|
-
console.log(`You can now view ${styleText("bold", appName)} in the browser.`);
|
|
86
|
-
console.log();
|
|
87
|
-
if (urls.lanUrlForTerminal) {
|
|
88
|
-
console.log(` ${styleText("bold", "Local:")} ${urls.localUrlForTerminal}`);
|
|
89
|
-
console.log(` ${styleText("bold", "On Your Network:")} ${urls.lanUrlForTerminal}`);
|
|
90
|
-
} else console.log(` ${urls.localUrlForTerminal}`);
|
|
91
|
-
console.log();
|
|
92
|
-
console.log("Note that the development build is not optimized.");
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* 准备Url 数据
|
|
96
|
-
*/
|
|
97
|
-
function prepareUrls(options) {
|
|
98
|
-
const { protocol, host, port, pathname = "/" } = options;
|
|
99
|
-
function formatUrl(hostname) {
|
|
100
|
-
return url.format({
|
|
101
|
-
protocol,
|
|
102
|
-
hostname,
|
|
103
|
-
port,
|
|
104
|
-
pathname
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function prettyPrintUrl(hostname) {
|
|
108
|
-
return url.format({
|
|
109
|
-
protocol,
|
|
110
|
-
hostname,
|
|
111
|
-
port: styleText("bold", String(port)),
|
|
112
|
-
pathname
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
const isUnspecifiedHost = host === "0.0.0.0" || host === "::";
|
|
116
|
-
let prettyHost;
|
|
117
|
-
let lanUrlForConfig;
|
|
118
|
-
let lanUrlForTerminal;
|
|
119
|
-
if (isUnspecifiedHost) {
|
|
120
|
-
prettyHost = "localhost";
|
|
121
|
-
try {
|
|
122
|
-
lanUrlForConfig = ip();
|
|
123
|
-
if (lanUrlForConfig) if (/^10\.|^172\.(1[6-9]|2\d|3[01])\.|^192\.168\./.test(lanUrlForConfig)) lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
|
|
124
|
-
else lanUrlForConfig = void 0;
|
|
125
|
-
} catch {}
|
|
126
|
-
} else prettyHost = host;
|
|
127
|
-
const localUrlForTerminal = prettyPrintUrl(prettyHost);
|
|
128
|
-
const localUrlForBrowser = formatUrl(prettyHost);
|
|
129
|
-
return {
|
|
130
|
-
lanUrlForConfig,
|
|
131
|
-
lanUrlForTerminal,
|
|
132
|
-
localUrlForTerminal,
|
|
133
|
-
localUrlForBrowser
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* 选择端口
|
|
138
|
-
* @param defaultPort 默认端口
|
|
139
|
-
* @param host 域名
|
|
140
|
-
*/
|
|
141
|
-
async function choosePort(options) {
|
|
142
|
-
try {
|
|
143
|
-
const port = await getPort(options);
|
|
144
|
-
if (port === options.port) return port;
|
|
145
|
-
const message = process.platform !== "win32" && port < 1024 && !isRoot() ? `Admin permissions are required to run a server on a port below 1024.` : `Something is already running on port ${port}.`;
|
|
146
|
-
if (isInteractive$1) {
|
|
147
|
-
clearConsole();
|
|
148
|
-
return (await prompts({
|
|
149
|
-
type: "confirm",
|
|
150
|
-
name: "shouldChangePort",
|
|
151
|
-
message: styleText("yellow", message) + "\n\nWould you like to run the app on another port instead",
|
|
152
|
-
initial: true
|
|
153
|
-
})).shouldChangePort ? port : void 0;
|
|
154
|
-
} else {
|
|
155
|
-
console.log(styleText("red", message));
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
} catch (error) {
|
|
159
|
-
throw new Error(styleText("red", `Could not find an open port at ${styleText("bold", options.host)}.`) + "\n" + ("Network error message: " + error.message || error) + "\n");
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* 编辑webpack配置
|
|
164
|
-
*/
|
|
165
|
-
function createCompiler(options) {
|
|
166
|
-
const { appName, config, urls } = options;
|
|
167
|
-
let compiler;
|
|
168
|
-
try {
|
|
169
|
-
compiler = rspack(config);
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.log(styleText("red", "Failed to compile."));
|
|
172
|
-
console.log();
|
|
173
|
-
console.log(error.message || error);
|
|
174
|
-
console.log();
|
|
175
|
-
exit(1);
|
|
176
|
-
}
|
|
177
|
-
compiler.hooks.invalid.tap("invalid", () => {
|
|
178
|
-
if (isInteractive$1) clearConsole();
|
|
179
|
-
console.log("Compiling...");
|
|
180
|
-
});
|
|
181
|
-
let isFirstCompile = true;
|
|
182
|
-
compiler.hooks.done.tap("done", async (stats) => {
|
|
183
|
-
if (isInteractive$1) clearConsole();
|
|
184
|
-
const statsData = stats.toJson({
|
|
185
|
-
all: false,
|
|
186
|
-
warnings: true,
|
|
187
|
-
errors: true
|
|
188
|
-
});
|
|
189
|
-
const errors = statsData.errors ?? [];
|
|
190
|
-
const warnings = statsData.warnings ?? [];
|
|
191
|
-
const isSuccessful = errors.length === 0 && warnings.length === 0;
|
|
192
|
-
if (isSuccessful) console.log(styleText("green", "Compiled successfully!"));
|
|
193
|
-
if (isSuccessful && (isInteractive$1 || isFirstCompile)) printInstructions(appName, urls);
|
|
194
|
-
isFirstCompile = false;
|
|
195
|
-
if (errors.length > 0) {
|
|
196
|
-
if (errors.length > 1) errors.length = 1;
|
|
197
|
-
console.log(styleText("red", "Failed to compile.\n"));
|
|
198
|
-
console.log(errors.join("\n\n"));
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (warnings.length > 0) {
|
|
202
|
-
console.log(styleText("yellow", "Compiled with warnings.\n"));
|
|
203
|
-
console.log(warnings.join("\n\n"));
|
|
204
|
-
console.log("\nSearch for the " + styleText("underline", styleText("yellow", "keywords")) + " to learn more about each warning.");
|
|
205
|
-
console.log("To ignore, add " + styleText("cyan", "// eslint-disable-next-line") + " to the line before.\n");
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
return compiler;
|
|
209
|
-
}
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region utils/escape-string-regexp.ts
|
|
212
|
-
function escapeStringRegexp(string) {
|
|
213
|
-
return string.replaceAll(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`).replaceAll("-", String.raw`\x2d`);
|
|
214
|
-
}
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region utils/ignored-files.ts
|
|
217
|
-
function ignoredFiles(appSource) {
|
|
218
|
-
return new RegExp(`^(?!${escapeStringRegexp(path.normalize(appSource + "/").replaceAll(/\\+/g, "/"))}).+/node_modules/`, "g");
|
|
219
|
-
}
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region rspack-dev-server.ts
|
|
222
|
-
function createDevelopmentServerConfig() {
|
|
223
|
-
return {
|
|
224
|
-
allowedHosts: "all",
|
|
225
|
-
client: { overlay: true },
|
|
226
|
-
headers: {
|
|
227
|
-
"Access-Control-Allow-Origin": "*",
|
|
228
|
-
"Access-Control-Allow-Methods": "*",
|
|
229
|
-
"Access-Control-Allow-Headers": "*"
|
|
230
|
-
},
|
|
231
|
-
compress: true,
|
|
232
|
-
static: {
|
|
233
|
-
directory: paths_default.appPublic,
|
|
234
|
-
publicPath: [paths_default.publicUrlOrPath],
|
|
235
|
-
watch: { ignored: ignoredFiles(paths_default.appSrc) }
|
|
236
|
-
},
|
|
237
|
-
devMiddleware: { publicPath: paths_default.publicUrlOrPath.slice(0, -1) },
|
|
238
|
-
historyApiFallback: {
|
|
239
|
-
disableDotRule: true,
|
|
240
|
-
index: paths_default.publicUrlOrPath
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region scripts/dev.ts
|
|
246
|
-
const require = createRequire(import.meta.url);
|
|
247
|
-
const isInteractive = process.stdout.isTTY;
|
|
248
|
-
const developmentServerConfig = {
|
|
249
|
-
PORT: 3e3,
|
|
250
|
-
HOST: "0.0.0.0",
|
|
251
|
-
PROTOCOL: "http"
|
|
252
|
-
};
|
|
253
|
-
async function startDevelopment() {
|
|
254
|
-
try {
|
|
255
|
-
const port = await choosePort({ port: developmentServerConfig.PORT });
|
|
256
|
-
if (port === void 0) return;
|
|
257
|
-
const config = await createRspackConfig();
|
|
258
|
-
const appName = require(paths_default.appPackageJson).name;
|
|
259
|
-
const urls = prepareUrls({
|
|
260
|
-
protocol: developmentServerConfig.PROTOCOL,
|
|
261
|
-
host: developmentServerConfig.HOST,
|
|
262
|
-
port,
|
|
263
|
-
pathname: paths_default.publicUrlOrPath.slice(0, -1)
|
|
264
|
-
});
|
|
265
|
-
const localUrlForBrowser = new URL(urls.localUrlForBrowser);
|
|
266
|
-
const compiler = createCompiler({
|
|
267
|
-
appName,
|
|
268
|
-
config,
|
|
269
|
-
urls
|
|
270
|
-
});
|
|
271
|
-
const developmentServer = new RspackDevServer({
|
|
272
|
-
...createDevelopmentServerConfig(),
|
|
273
|
-
host: localUrlForBrowser.hostname,
|
|
274
|
-
port: localUrlForBrowser.port,
|
|
275
|
-
open: true
|
|
276
|
-
}, compiler);
|
|
277
|
-
developmentServer.startCallback((error) => {
|
|
278
|
-
if (isInteractive) clearConsole();
|
|
279
|
-
console.log(styleText("cyan", "Starting the development server...\n"));
|
|
280
|
-
});
|
|
281
|
-
developmentServer.stopCallback((error) => {
|
|
282
|
-
if (error) console.log("Server stopped.", error);
|
|
283
|
-
});
|
|
284
|
-
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => {
|
|
285
|
-
developmentServer.stop();
|
|
286
|
-
process.exit();
|
|
287
|
-
});
|
|
288
|
-
if (process.env.CI !== "true") process.stdin.on("end", function() {
|
|
289
|
-
developmentServer.stop();
|
|
290
|
-
exit();
|
|
291
|
-
});
|
|
292
|
-
} catch (error) {
|
|
293
|
-
if (error?.message) console.log(error.message);
|
|
294
|
-
exit(1);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
await startDevelopment();
|
|
298
|
-
//#endregion
|
|
299
|
-
export {};
|
|
1
|
+
import { t as startDev } from "../dev-D0bbZds7.js";
|
|
2
|
+
export { startDev };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnific/react-scripts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React app scripts based on Rspack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"bin": {
|
|
22
22
|
"react-scripts": "./dist/index.js"
|
|
23
23
|
},
|
|
24
|
-
"main": "./dist/main.
|
|
24
|
+
"main": "./dist/main.js",
|
|
25
25
|
"module": "./dist/main.js",
|
|
26
26
|
"types": "./dist/main.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/main.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"default": "./dist/main.js",
|
|
31
|
+
"import": "./dist/main.js"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
@@ -39,30 +39,30 @@
|
|
|
39
39
|
"node": ">=22.12.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@rspack/cli": "^2.0.
|
|
43
|
-
"@rspack/core": "^2.0.
|
|
42
|
+
"@rspack/cli": "^2.0.3",
|
|
43
|
+
"@rspack/core": "^2.0.3",
|
|
44
44
|
"@rspack/dev-server": "^2.0.1",
|
|
45
45
|
"@rspack/plugin-react-refresh": "^2.0.0",
|
|
46
|
-
"@tailwindcss/postcss": "^4.
|
|
46
|
+
"@tailwindcss/postcss": "^4.3.0",
|
|
47
47
|
"get-port": "^7.2.0",
|
|
48
48
|
"less": "^4.6.4",
|
|
49
49
|
"less-loader": "^12.3.2",
|
|
50
|
-
"postcss": "^8.5.
|
|
50
|
+
"postcss": "^8.5.14",
|
|
51
51
|
"postcss-loader": "^8.2.0",
|
|
52
52
|
"pretty-bytes": "^7.1.0",
|
|
53
53
|
"prompts": "^2.4.2",
|
|
54
54
|
"react-refresh": "^0.18.0",
|
|
55
55
|
"sass-embedded": "^1.93.2",
|
|
56
|
-
"sass-loader": "^16.0.
|
|
57
|
-
"
|
|
56
|
+
"sass-loader": "^16.0.8",
|
|
57
|
+
"webpack-merge": "^6.0.1",
|
|
58
|
+
"@omnific/types": "0.0.6"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@types/prompts": "^2.4.9"
|
|
61
|
-
"tsdown": "^0.21.10"
|
|
61
|
+
"@types/prompts": "^2.4.9"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "tsdown -c tsdown.config.mjs",
|
|
65
|
-
"release": "pnpm
|
|
65
|
+
"release": "pnpm publish --access public",
|
|
66
66
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
67
67
|
}
|
|
68
68
|
}
|
package/dist/env-DxzdvROc.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region utils/env.ts
|
|
2
|
-
const DEVELOPMENT = "development";
|
|
3
|
-
const PRODUCTION = "production";
|
|
4
|
-
const envKeys = ["NODE_ENV", "SCRIPT"];
|
|
5
|
-
/**
|
|
6
|
-
* 设置环境变量
|
|
7
|
-
* @param env
|
|
8
|
-
*/
|
|
9
|
-
function setEnv(data) {
|
|
10
|
-
for (const key of envKeys) if (data[key]) process.env[key] = data[key];
|
|
11
|
-
}
|
|
12
|
-
function getEnv() {
|
|
13
|
-
return process.env.NODE_ENV || "development";
|
|
14
|
-
}
|
|
15
|
-
function isDevelopment() {
|
|
16
|
-
return getEnv() === DEVELOPMENT;
|
|
17
|
-
}
|
|
18
|
-
function isProduction() {
|
|
19
|
-
return getEnv() === PRODUCTION;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { isProduction as a, isDevelopment as i, PRODUCTION as n, setEnv as o, getEnv as r, DEVELOPMENT as t };
|
package/dist/main.cjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
|
-
let node_fs = require("node:fs");
|
|
25
|
-
node_fs = __toESM(node_fs, 1);
|
|
26
|
-
let node_path = require("node:path");
|
|
27
|
-
node_path = __toESM(node_path, 1);
|
|
28
|
-
//#region utils/env.ts
|
|
29
|
-
const DEVELOPMENT = "development";
|
|
30
|
-
const PRODUCTION = "production";
|
|
31
|
-
function getEnv() {
|
|
32
|
-
return process.env.NODE_ENV || "development";
|
|
33
|
-
}
|
|
34
|
-
function isDevelopment() {
|
|
35
|
-
return getEnv() === DEVELOPMENT;
|
|
36
|
-
}
|
|
37
|
-
function isProduction() {
|
|
38
|
-
return getEnv() === PRODUCTION;
|
|
39
|
-
}
|
|
40
|
-
function isBuild() {
|
|
41
|
-
return process.env.SCRIPT === "build";
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region paths.ts
|
|
45
|
-
const appDirectory = node_fs.default.realpathSync(process.cwd());
|
|
46
|
-
function resolveApp(relativePath) {
|
|
47
|
-
return node_path.default.resolve(appDirectory, relativePath);
|
|
48
|
-
}
|
|
49
|
-
var paths_default = {
|
|
50
|
-
appSrc: resolveApp("src"),
|
|
51
|
-
appPath: resolveApp("."),
|
|
52
|
-
appBuild: resolveApp("build"),
|
|
53
|
-
appIndexJs: resolveApp("src/index.tsx"),
|
|
54
|
-
publicUrlOrPath: isDevelopment() ? "/" : "./",
|
|
55
|
-
appHtml: resolveApp("public/index.html"),
|
|
56
|
-
appTsConfig: resolveApp("./tsconfig.json"),
|
|
57
|
-
appNodeModules: resolveApp("node_modules"),
|
|
58
|
-
appPackageJson: resolveApp("package.json"),
|
|
59
|
-
appPublic: resolveApp("public"),
|
|
60
|
-
config: resolveApp("react-scripts.config")
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region main.ts
|
|
64
|
-
function defineConfig(config) {
|
|
65
|
-
return config;
|
|
66
|
-
}
|
|
67
|
-
//#endregion
|
|
68
|
-
exports.defineConfig = defineConfig;
|
|
69
|
-
exports.getEnv = getEnv;
|
|
70
|
-
exports.isBuild = isBuild;
|
|
71
|
-
exports.isDevelopment = isDevelopment;
|
|
72
|
-
exports.isProduction = isProduction;
|
|
73
|
-
exports.paths = paths_default;
|
package/dist/main.d.cts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Configuration } from "@rspack/core";
|
|
2
|
-
|
|
3
|
-
//#region paths.d.ts
|
|
4
|
-
declare const _default: {
|
|
5
|
-
appSrc: string;
|
|
6
|
-
appPath: string;
|
|
7
|
-
appBuild: string;
|
|
8
|
-
appIndexJs: string;
|
|
9
|
-
publicUrlOrPath: string;
|
|
10
|
-
appHtml: string;
|
|
11
|
-
appTsConfig: string;
|
|
12
|
-
appNodeModules: string;
|
|
13
|
-
appPackageJson: string;
|
|
14
|
-
appPublic: string;
|
|
15
|
-
config: string;
|
|
16
|
-
};
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region utils/env.d.ts
|
|
19
|
-
declare function getEnv(): string;
|
|
20
|
-
declare function isDevelopment(): boolean;
|
|
21
|
-
declare function isProduction(): boolean;
|
|
22
|
-
declare function isBuild(): boolean;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region main.d.ts
|
|
25
|
-
type ReactScriptsConfig = {
|
|
26
|
-
configureRspack?: (config: Configuration) => Configuration;
|
|
27
|
-
};
|
|
28
|
-
declare function defineConfig(config: ReactScriptsConfig): ReactScriptsConfig;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { ReactScriptsConfig, defineConfig, getEnv, isBuild, isDevelopment, isProduction, _default as paths };
|