react-client 1.0.28 ā 1.0.31
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/cli/commands/build.js +19 -25
- package/dist/cli/commands/dev.js +289 -205
- package/dist/cli/commands/init.js +34 -40
- package/dist/cli/commands/preview.js +41 -47
- package/dist/cli/index.js +49 -50
- package/dist/cli/types.js +1 -3
- package/dist/index.js +2 -20
- package/dist/server/broadcastManager.js +8 -15
- package/dist/utils/loadConfig.js +24 -63
- package/dist/utils/string.js +1 -4
- package/package.json +7 -6
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const esbuild_1 = __importDefault(require("esbuild"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
-
const loadConfig_1 = require("../../utils/loadConfig");
|
|
12
|
-
async function build() {
|
|
1
|
+
import esbuild from 'esbuild';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { loadReactClientConfig } from '../../utils/loadConfig';
|
|
6
|
+
export default async function build() {
|
|
13
7
|
const root = process.cwd();
|
|
14
|
-
const config = await
|
|
15
|
-
const appRoot =
|
|
16
|
-
const outDir =
|
|
17
|
-
console.log(
|
|
18
|
-
console.log(
|
|
19
|
-
console.log(
|
|
20
|
-
const entry =
|
|
21
|
-
if (!
|
|
22
|
-
console.error(
|
|
8
|
+
const config = await loadReactClientConfig(root);
|
|
9
|
+
const appRoot = path.resolve(root, config.root || '.');
|
|
10
|
+
const outDir = path.join(appRoot, config.build?.outDir || '.react-client/build');
|
|
11
|
+
console.log(chalk.cyan(`\nšļø Building project...`));
|
|
12
|
+
console.log(chalk.gray(`Root: ${appRoot}`));
|
|
13
|
+
console.log(chalk.gray(`Output: ${outDir}\n`));
|
|
14
|
+
const entry = path.join(appRoot, 'src', 'main.tsx');
|
|
15
|
+
if (!fs.existsSync(entry)) {
|
|
16
|
+
console.error(chalk.red('ā Entry not found: src/main.tsx'));
|
|
23
17
|
process.exit(1);
|
|
24
18
|
}
|
|
25
|
-
await
|
|
19
|
+
await fs.ensureDir(outDir);
|
|
26
20
|
try {
|
|
27
|
-
await
|
|
21
|
+
await esbuild.build({
|
|
28
22
|
entryPoints: [entry],
|
|
29
23
|
bundle: true,
|
|
30
24
|
minify: true,
|
|
@@ -33,8 +27,8 @@ async function build() {
|
|
|
33
27
|
define: { 'process.env.NODE_ENV': '"production"' },
|
|
34
28
|
loader: { '.ts': 'ts', '.tsx': 'tsx', '.js': 'jsx', '.jsx': 'jsx' },
|
|
35
29
|
});
|
|
36
|
-
console.log(
|
|
37
|
-
console.log(
|
|
30
|
+
console.log(chalk.green(`ā
Build completed successfully!`));
|
|
31
|
+
console.log(chalk.gray(`Output directory: ${outDir}`));
|
|
38
32
|
}
|
|
39
33
|
catch (err) {
|
|
40
34
|
const msg = err instanceof Error ? err.message : String(err);
|