-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
74 lines (69 loc) · 2.14 KB
/
Copy pathesbuild.js
File metadata and controls
74 lines (69 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const esbuild = require('esbuild');
const copyStaticFiles = require('esbuild-copy-static-files');
const path = require('path');
const fs = require('fs');
const envFiles = [
{
src: path.resolve('core/uniMatch/user/user.env'),
dest: path.resolve('dist/apps/RestApi/user.env')
},
{
src: path.resolve('core/uniMatch/status/status.env'),
dest: path.resolve('dist/apps/RestApi/status.env')
},
{
src: path.resolve('core/uniMatch/notifications/notifications.env'),
dest: path.resolve('dist/apps/RestApi/notifications.env')
},
{
src: path.resolve('core/uniMatch/message/message.env'),
dest: path.resolve('dist/apps/RestApi/message.env')
},
{
src: path.resolve('core/uniMatch/matching/matching.env'),
dest: path.resolve('dist/apps/RestApi/matching.env')
},
{
src: path.resolve('core/uniMatch/event/event.env'),
dest: path.resolve('dist/apps/RestApi/event.env')
},
{
src: path.resolve('core/shared/shared.env'),
dest: path.resolve('dist/apps/RestApi/shared.env')
},
{
src: path.resolve('apps/RestApi/main.env'),
dest: path.resolve('dist/apps/RestApi/main.env')
}
];
const copyEnvFiles = (files) => {
files.forEach(({ src, dest }) => {
if (fs.existsSync(src)) {
fs.copyFileSync(src, dest);
} else {
console.warn(`No se encontró el archivo ${src}`);
}
});
};
// Opciones comunes para build
const buildOptions = {
entryPoints: ['./apps/RestApi/Main.ts'],
bundle: true,
platform: 'node',
outfile: './dist/apps/RestApi/Main.js',
sourcemap: true, // Generar source maps
minify: process.env.NODE_ENV === 'production', // Minificar en producción
plugins: [
copyStaticFiles({
src: './apps/static',
dest: './dist/static',
}),
],
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
},
};
esbuild.build(buildOptions).then(() => {
copyEnvFiles(envFiles);
console.log('Build completado con éxito.');
}).catch(() => process.exit(1));