makepack 1.5.20 → 1.5.22
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/README.md +122 -122
- package/package.json +61 -61
- package/src/actions/build/index.js +109 -109
- package/src/actions/create/files/App.js +51 -51
- package/src/actions/create/files/config.js +54 -54
- package/src/actions/create/files/gitignore.js +8 -8
- package/src/actions/create/files/package-json.js +54 -54
- package/src/actions/create/files/project-js.js +12 -12
- package/src/actions/create/files/project-jsx.js +50 -50
- package/src/actions/create/files/project-ts.js +10 -10
- package/src/actions/create/files/project-tsx.js +50 -50
- package/src/actions/create/files/readme.md.js +62 -62
- package/src/actions/create/files/tsconfig.js +33 -33
- package/src/actions/create/index.js +105 -105
- package/src/actions/create/makeFiles.js +64 -64
- package/src/actions/publish/index.js +20 -20
- package/src/actions/start/express.js +25 -25
- package/src/actions/start/index.js +76 -76
- package/src/actions/start/vite.js +56 -56
- package/src/helpers.js +36 -36
- package/src/index.js +33 -33
- package/src/makepack-config.js +58 -58
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import fs from 'fs-extra'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { logger } from '../../helpers.js'
|
|
4
|
-
import makepackConfig from '../../makepack-config.js';
|
|
5
|
-
import esbuild from 'esbuild';
|
|
6
|
-
import chokidar from 'chokidar';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
import { spawn } from 'child_process';
|
|
9
|
-
let __filename, __dirname;
|
|
10
|
-
|
|
11
|
-
if (typeof import.meta.url !== 'undefined') {
|
|
12
|
-
__filename = fileURLToPath(import.meta.url);
|
|
13
|
-
__dirname = path.dirname(__filename);
|
|
14
|
-
} else {
|
|
15
|
-
__filename = __filename;
|
|
16
|
-
__dirname = __dirname;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let server = null;
|
|
20
|
-
function startServer() {
|
|
21
|
-
if (server) {
|
|
22
|
-
server.kill('SIGINT');
|
|
23
|
-
server = null;
|
|
24
|
-
}
|
|
25
|
-
server = spawn('node', [path.resolve(__dirname, 'express.js')], {});
|
|
26
|
-
server.stdout.on('data', (data) => {
|
|
27
|
-
console.log(data.toString().trim());
|
|
28
|
-
});
|
|
29
|
-
server.stderr.on('data', (data) => {
|
|
30
|
-
console.error(data.toString().trim());
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const start = async () => {
|
|
35
|
-
const config = await makepackConfig()
|
|
36
|
-
const exists = fs.existsSync(path.join(process.cwd(), config.start.entry))
|
|
37
|
-
if (!exists) {
|
|
38
|
-
logger.error(`Entry file ${entry} does not exist. please check your config file`)
|
|
39
|
-
process.exit(1)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const expressjs = path.join(process.cwd(), 'express.js')
|
|
43
|
-
const expressts = path.join(process.cwd(), 'express.ts')
|
|
44
|
-
|
|
45
|
-
if (fs.existsSync(expressjs) || fs.existsSync(expressts)) {
|
|
46
|
-
let filename = fs.existsSync(expressjs) ? "express.js" : "express.ts";
|
|
47
|
-
let outfile = path.resolve(__dirname, 'user-express.js')
|
|
48
|
-
|
|
49
|
-
const ctx = await esbuild.context({
|
|
50
|
-
entryPoints: [filename],
|
|
51
|
-
outfile: path.resolve(__dirname, 'user-express.js'),
|
|
52
|
-
bundle: true,
|
|
53
|
-
format: 'esm',
|
|
54
|
-
platform: 'node',
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
ctx.watch()
|
|
59
|
-
|
|
60
|
-
const watcher = chokidar.watch(outfile, {
|
|
61
|
-
persistent: true,
|
|
62
|
-
ignoreInitial: true,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
watcher.on('change', async () => {
|
|
66
|
-
startServer(config)
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
process.on('SIGINT', async () => {
|
|
70
|
-
watcher.close();
|
|
71
|
-
process.exit(0);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
startServer(config)
|
|
75
|
-
}
|
|
76
|
-
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { logger } from '../../helpers.js'
|
|
4
|
+
import makepackConfig from '../../makepack-config.js';
|
|
5
|
+
import esbuild from 'esbuild';
|
|
6
|
+
import chokidar from 'chokidar';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { spawn } from 'child_process';
|
|
9
|
+
let __filename, __dirname;
|
|
10
|
+
|
|
11
|
+
if (typeof import.meta.url !== 'undefined') {
|
|
12
|
+
__filename = fileURLToPath(import.meta.url);
|
|
13
|
+
__dirname = path.dirname(__filename);
|
|
14
|
+
} else {
|
|
15
|
+
__filename = __filename;
|
|
16
|
+
__dirname = __dirname;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let server = null;
|
|
20
|
+
function startServer() {
|
|
21
|
+
if (server) {
|
|
22
|
+
server.kill('SIGINT');
|
|
23
|
+
server = null;
|
|
24
|
+
}
|
|
25
|
+
server = spawn('node', [path.resolve(__dirname, 'express.js')], {});
|
|
26
|
+
server.stdout.on('data', (data) => {
|
|
27
|
+
console.log(data.toString().trim());
|
|
28
|
+
});
|
|
29
|
+
server.stderr.on('data', (data) => {
|
|
30
|
+
console.error(data.toString().trim());
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const start = async () => {
|
|
35
|
+
const config = await makepackConfig()
|
|
36
|
+
const exists = fs.existsSync(path.join(process.cwd(), config.start.entry))
|
|
37
|
+
if (!exists) {
|
|
38
|
+
logger.error(`Entry file ${entry} does not exist. please check your config file`)
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const expressjs = path.join(process.cwd(), 'express.js')
|
|
43
|
+
const expressts = path.join(process.cwd(), 'express.ts')
|
|
44
|
+
|
|
45
|
+
if (fs.existsSync(expressjs) || fs.existsSync(expressts)) {
|
|
46
|
+
let filename = fs.existsSync(expressjs) ? "express.js" : "express.ts";
|
|
47
|
+
let outfile = path.resolve(__dirname, 'user-express.js')
|
|
48
|
+
|
|
49
|
+
const ctx = await esbuild.context({
|
|
50
|
+
entryPoints: [filename],
|
|
51
|
+
outfile: path.resolve(__dirname, 'user-express.js'),
|
|
52
|
+
bundle: true,
|
|
53
|
+
format: 'esm',
|
|
54
|
+
platform: 'node',
|
|
55
|
+
packages: 'external',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
ctx.watch()
|
|
59
|
+
|
|
60
|
+
const watcher = chokidar.watch(outfile, {
|
|
61
|
+
persistent: true,
|
|
62
|
+
ignoreInitial: true,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
watcher.on('change', async () => {
|
|
66
|
+
startServer(config)
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
process.on('SIGINT', async () => {
|
|
70
|
+
watcher.close();
|
|
71
|
+
process.exit(0);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
startServer(config)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
77
|
export default start
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
// import react from '@vitejs/plugin-react'
|
|
2
|
-
import { createServer as createViteServer } from 'vite';
|
|
3
|
-
import { logger } from '../../helpers.js'
|
|
4
|
-
import makepackConfig from '../../makepack-config.js';
|
|
5
|
-
|
|
6
|
-
const viteSetup = async (app) => {
|
|
7
|
-
const config = await makepackConfig()
|
|
8
|
-
const viteConfig = {
|
|
9
|
-
root: process.cwd(),
|
|
10
|
-
base: "/",
|
|
11
|
-
// plugins: [react()],
|
|
12
|
-
server: {
|
|
13
|
-
middlewareMode: true,
|
|
14
|
-
},
|
|
15
|
-
customLogger: {
|
|
16
|
-
info: (msg) => {
|
|
17
|
-
logger.info(msg)
|
|
18
|
-
},
|
|
19
|
-
warn: (msg) => logger.warning(msg),
|
|
20
|
-
error: (msg) => logger.error(msg),
|
|
21
|
-
},
|
|
22
|
-
appType: 'custom'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const vite = await createViteServer(viteConfig);
|
|
26
|
-
app.use(vite.middlewares);
|
|
27
|
-
|
|
28
|
-
app.get('*', async (req, res, next) => {
|
|
29
|
-
const url = req.originalUrl;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
let template = await vite.transformIndexHtml(url, `
|
|
33
|
-
<!doctype html>
|
|
34
|
-
<html lang="en">
|
|
35
|
-
<head>
|
|
36
|
-
<meta charset="UTF-8" />
|
|
37
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
38
|
-
</head>
|
|
39
|
-
<body>
|
|
40
|
-
<div id="root"></div>
|
|
41
|
-
<script type="module" src="${config.start.entry}"></script>
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|
|
44
|
-
`);
|
|
45
|
-
|
|
46
|
-
res.status(200).set({
|
|
47
|
-
'Content-Type': 'text/html'
|
|
48
|
-
}).end(template);
|
|
49
|
-
} catch (e) {
|
|
50
|
-
vite.ssrFixStacktrace(e);
|
|
51
|
-
next(e);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
// import react from '@vitejs/plugin-react'
|
|
2
|
+
import { createServer as createViteServer } from 'vite';
|
|
3
|
+
import { logger } from '../../helpers.js'
|
|
4
|
+
import makepackConfig from '../../makepack-config.js';
|
|
5
|
+
|
|
6
|
+
const viteSetup = async (app) => {
|
|
7
|
+
const config = await makepackConfig()
|
|
8
|
+
const viteConfig = {
|
|
9
|
+
root: process.cwd(),
|
|
10
|
+
base: "/",
|
|
11
|
+
// plugins: [react()],
|
|
12
|
+
server: {
|
|
13
|
+
middlewareMode: true,
|
|
14
|
+
},
|
|
15
|
+
customLogger: {
|
|
16
|
+
info: (msg) => {
|
|
17
|
+
logger.info(msg)
|
|
18
|
+
},
|
|
19
|
+
warn: (msg) => logger.warning(msg),
|
|
20
|
+
error: (msg) => logger.error(msg),
|
|
21
|
+
},
|
|
22
|
+
appType: 'custom'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const vite = await createViteServer(viteConfig);
|
|
26
|
+
app.use(vite.middlewares);
|
|
27
|
+
|
|
28
|
+
app.get('*', async (req, res, next) => {
|
|
29
|
+
const url = req.originalUrl;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
let template = await vite.transformIndexHtml(url, `
|
|
33
|
+
<!doctype html>
|
|
34
|
+
<html lang="en">
|
|
35
|
+
<head>
|
|
36
|
+
<meta charset="UTF-8" />
|
|
37
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<div id="root"></div>
|
|
41
|
+
<script type="module" src="${config.start.entry}"></script>
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
res.status(200).set({
|
|
47
|
+
'Content-Type': 'text/html'
|
|
48
|
+
}).end(template);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
vite.ssrFixStacktrace(e);
|
|
51
|
+
next(e);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
57
|
export default viteSetup
|
package/src/helpers.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import child_process from 'child_process'
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import figures from 'figures';
|
|
4
|
-
|
|
5
|
-
export const execSync = (command, option = {}) => {
|
|
6
|
-
try {
|
|
7
|
-
const result = child_process.execSync(command, {
|
|
8
|
-
encoding: "utf-8",
|
|
9
|
-
stdio: 'inherit',
|
|
10
|
-
...option
|
|
11
|
-
});
|
|
12
|
-
result && console.log(result);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error(`Command failed: ${error.message}`);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const logger = {
|
|
22
|
-
info: (message, prefix = 'INFO', icon = true) => {
|
|
23
|
-
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
24
|
-
},
|
|
25
|
-
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
26
|
-
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
27
|
-
},
|
|
28
|
-
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
29
|
-
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
30
|
-
},
|
|
31
|
-
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
32
|
-
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
33
|
-
},
|
|
34
|
-
custom: (icon, color, label, message) => {
|
|
35
|
-
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
36
|
-
},
|
|
1
|
+
import child_process from 'child_process'
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import figures from 'figures';
|
|
4
|
+
|
|
5
|
+
export const execSync = (command, option = {}) => {
|
|
6
|
+
try {
|
|
7
|
+
const result = child_process.execSync(command, {
|
|
8
|
+
encoding: "utf-8",
|
|
9
|
+
stdio: 'inherit',
|
|
10
|
+
...option
|
|
11
|
+
});
|
|
12
|
+
result && console.log(result);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(`Command failed: ${error.message}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const logger = {
|
|
22
|
+
info: (message, prefix = 'INFO', icon = true) => {
|
|
23
|
+
console.log(`${icon ? chalk.blue(figures.info) + " " : ""}${chalk.cyan.bold(prefix)} ${message}`);
|
|
24
|
+
},
|
|
25
|
+
success: (message, prefix = 'SUCCESS:', icon = true) => {
|
|
26
|
+
console.log(`${icon ? chalk.green(figures.tick) + " " : ""}${chalk.green.bold(prefix)} ${message}`);
|
|
27
|
+
},
|
|
28
|
+
warning: (message, prefix = 'WARNING:', icon = true) => {
|
|
29
|
+
console.log(`${icon ? chalk.yellow(figures.warning) + " " : ""}${chalk.yellow.bold(prefix)} ${message}`);
|
|
30
|
+
},
|
|
31
|
+
error: (message, prefix = 'ERROR:', icon = true) => {
|
|
32
|
+
console.log(`${icon ? chalk.red(figures.cross) + " " : ""}${chalk.red.bold(prefix)} ${message}`);
|
|
33
|
+
},
|
|
34
|
+
custom: (icon, color, label, message) => {
|
|
35
|
+
console.log(`${chalk[color](icon)} ${chalk[color].bold(`${label}:`)} ${message}`);
|
|
36
|
+
},
|
|
37
37
|
};
|
package/src/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import start from "./actions/start/index.js";
|
|
5
|
-
import build from "./actions/build/index.js";
|
|
6
|
-
import create from "./actions/create/index.js";
|
|
7
|
-
import publish from "./actions/publish/index.js";
|
|
8
|
-
|
|
9
|
-
const program = new Command();
|
|
10
|
-
|
|
11
|
-
program.name("Makepack").description("Usages");
|
|
12
|
-
|
|
13
|
-
program
|
|
14
|
-
.command("create")
|
|
15
|
-
.description("create a new project")
|
|
16
|
-
.action(create);
|
|
17
|
-
|
|
18
|
-
program
|
|
19
|
-
.command("start")
|
|
20
|
-
.description("Start the server")
|
|
21
|
-
.action(start);
|
|
22
|
-
|
|
23
|
-
program
|
|
24
|
-
.command("build")
|
|
25
|
-
.description("Build the project")
|
|
26
|
-
.action(build);
|
|
27
|
-
|
|
28
|
-
program
|
|
29
|
-
.command("publish")
|
|
30
|
-
.description("Publish it to the npm repository")
|
|
31
|
-
.action(publish);
|
|
32
|
-
|
|
33
|
-
program.parse();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import start from "./actions/start/index.js";
|
|
5
|
+
import build from "./actions/build/index.js";
|
|
6
|
+
import create from "./actions/create/index.js";
|
|
7
|
+
import publish from "./actions/publish/index.js";
|
|
8
|
+
|
|
9
|
+
const program = new Command();
|
|
10
|
+
|
|
11
|
+
program.name("Makepack").description("Usages");
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.command("create")
|
|
15
|
+
.description("create a new project")
|
|
16
|
+
.action(create);
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.command("start")
|
|
20
|
+
.description("Start the server")
|
|
21
|
+
.action(start);
|
|
22
|
+
|
|
23
|
+
program
|
|
24
|
+
.command("build")
|
|
25
|
+
.description("Build the project")
|
|
26
|
+
.action(build);
|
|
27
|
+
|
|
28
|
+
program
|
|
29
|
+
.command("publish")
|
|
30
|
+
.description("Publish it to the npm repository")
|
|
31
|
+
.action(publish);
|
|
32
|
+
|
|
33
|
+
program.parse();
|
package/src/makepack-config.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { cosmiconfig } from "cosmiconfig";
|
|
2
|
-
|
|
3
|
-
const makepackConfig = async () => {
|
|
4
|
-
const explorer = cosmiconfig("makepack");
|
|
5
|
-
const configResult = await explorer.search();
|
|
6
|
-
|
|
7
|
-
const defaultConfig = {
|
|
8
|
-
build: {
|
|
9
|
-
outdir: "build",
|
|
10
|
-
types: true,
|
|
11
|
-
formatPackageJson: (p) => p,
|
|
12
|
-
configs: [
|
|
13
|
-
{
|
|
14
|
-
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
15
|
-
outdir: "",
|
|
16
|
-
format: "esm",
|
|
17
|
-
sourcemap: true,
|
|
18
|
-
minify: true,
|
|
19
|
-
jsx: 'automatic',
|
|
20
|
-
loader: {
|
|
21
|
-
'.ts': 'ts',
|
|
22
|
-
'.tsx': 'tsx'
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
27
|
-
outdir: "cjs",
|
|
28
|
-
format: "cjs",
|
|
29
|
-
sourcemap: true,
|
|
30
|
-
minify: true,
|
|
31
|
-
jsx: 'automatic',
|
|
32
|
-
loader: {
|
|
33
|
-
'.ts': 'ts',
|
|
34
|
-
'.tsx': 'tsx'
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
start: {
|
|
40
|
-
port: 5000,
|
|
41
|
-
entry: "App.tsx",
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (configResult && configResult.config) {
|
|
46
|
-
let fn = configResult.config;
|
|
47
|
-
if (typeof fn === 'function') {
|
|
48
|
-
const userConfig = fn(defaultConfig)
|
|
49
|
-
if (!userConfig) {
|
|
50
|
-
console.log("Config function must return a config object")
|
|
51
|
-
process.exit(1)
|
|
52
|
-
}
|
|
53
|
-
return userConfig
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return defaultConfig
|
|
57
|
-
}
|
|
58
|
-
|
|
1
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
2
|
+
|
|
3
|
+
const makepackConfig = async () => {
|
|
4
|
+
const explorer = cosmiconfig("makepack");
|
|
5
|
+
const configResult = await explorer.search();
|
|
6
|
+
|
|
7
|
+
const defaultConfig = {
|
|
8
|
+
build: {
|
|
9
|
+
outdir: "build",
|
|
10
|
+
types: true,
|
|
11
|
+
formatPackageJson: (p) => p,
|
|
12
|
+
configs: [
|
|
13
|
+
{
|
|
14
|
+
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
15
|
+
outdir: "",
|
|
16
|
+
format: "esm",
|
|
17
|
+
sourcemap: true,
|
|
18
|
+
minify: true,
|
|
19
|
+
jsx: 'automatic',
|
|
20
|
+
loader: {
|
|
21
|
+
'.ts': 'ts',
|
|
22
|
+
'.tsx': 'tsx'
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
entryPoints: "src/**/*.{tsx,ts,js,jsx}",
|
|
27
|
+
outdir: "cjs",
|
|
28
|
+
format: "cjs",
|
|
29
|
+
sourcemap: true,
|
|
30
|
+
minify: true,
|
|
31
|
+
jsx: 'automatic',
|
|
32
|
+
loader: {
|
|
33
|
+
'.ts': 'ts',
|
|
34
|
+
'.tsx': 'tsx'
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
start: {
|
|
40
|
+
port: 5000,
|
|
41
|
+
entry: "App.tsx",
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (configResult && configResult.config) {
|
|
46
|
+
let fn = configResult.config;
|
|
47
|
+
if (typeof fn === 'function') {
|
|
48
|
+
const userConfig = fn(defaultConfig)
|
|
49
|
+
if (!userConfig) {
|
|
50
|
+
console.log("Config function must return a config object")
|
|
51
|
+
process.exit(1)
|
|
52
|
+
}
|
|
53
|
+
return userConfig
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return defaultConfig
|
|
57
|
+
}
|
|
58
|
+
|
|
59
59
|
export default makepackConfig
|