2022-05-25 13:58:28 +00:00
|
|
|
import { build } from 'esbuild';
|
|
|
|
import { nodeExternalsPlugin } from 'esbuild-node-externals';
|
|
|
|
|
|
|
|
const isProd = Boolean(process.env.NODE_ENV === 'production');
|
2023-06-29 16:02:02 +00:00
|
|
|
const watch = Boolean(process.env.ESBUILD_WATCH);
|
2023-08-09 22:14:16 +00:00
|
|
|
const version = process.env.VERSION || 'dev';
|
2022-05-25 13:58:28 +00:00
|
|
|
|
|
|
|
build({
|
|
|
|
outfile: './dist/index.js',
|
|
|
|
bundle: true,
|
|
|
|
platform: 'node',
|
|
|
|
minify: isProd,
|
2023-06-29 16:02:02 +00:00
|
|
|
target: 'node18',
|
2022-05-25 13:58:28 +00:00
|
|
|
sourcemap: true,
|
|
|
|
format: 'cjs',
|
2023-08-09 22:14:16 +00:00
|
|
|
tsconfig: 'tsconfig.json',
|
2022-05-25 13:58:28 +00:00
|
|
|
watch,
|
|
|
|
plugins: [
|
|
|
|
// Exclude node_modules from the bundle since they will be packaged with the cli
|
|
|
|
nodeExternalsPlugin(),
|
|
|
|
],
|
|
|
|
define: {
|
|
|
|
'process.env.DEFAULT_APP_NAME': JSON.stringify(isProd ? 'Insomnia' : 'insomnia-app'),
|
2023-08-09 22:14:16 +00:00
|
|
|
'process.env.VERSION': JSON.stringify(isProd ? version : 'dev'),
|
2022-05-25 13:58:28 +00:00
|
|
|
'__DEV__': JSON.stringify(!isProd),
|
|
|
|
},
|
|
|
|
external: ['@getinsomnia/node-libcurl', 'mocha'],
|
|
|
|
entryPoints: ['./src/index.ts'],
|
|
|
|
});
|