-
Notifications
You must be signed in to change notification settings - Fork 33
/
esbuild.config.js
64 lines (58 loc) · 1.6 KB
/
esbuild.config.js
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
/* eslint-disable @typescript-eslint/no-require-imports, import/no-extraneous-dependencies, unicorn/prefer-top-level-await */
const esbuild = require('esbuild');
// Automatically exclude all node_modules from the bundled version
const {nodeExternalsPlugin} = require('esbuild-node-externals');
const {readdirSync} = require('fs');
const path = require('path');
const rulesDirectory = path.join(__dirname, 'src', 'rules');
const bundle = true;
const minify = true;
const platform = 'node';
const sourcemap = true;
const target = 'node16';
const plugins = [nodeExternalsPlugin()];
readdirSync(rulesDirectory).forEach((file) => {
const ruleFilePath = path.join(rulesDirectory, file);
const beginIndex = 0;
const endIndex = -3;
const ruleFileNameWithoutExtension = file.slice(beginIndex, endIndex);
esbuild
.build({
entryPoints: [ruleFilePath],
outfile: `dist/rules/${ruleFileNameWithoutExtension}.js`,
bundle,
minify,
platform,
sourcemap: false,
target,
plugins,
})
// eslint-disable-next-line unicorn/no-process-exit
.catch(() => process.exit(1));
});
esbuild
.build({
entryPoints: ['./src/api.ts'],
outfile: 'dist/api.js',
bundle,
minify,
platform,
sourcemap,
target,
plugins,
})
// eslint-disable-next-line unicorn/no-process-exit
.catch(() => process.exit(1));
esbuild
.build({
entryPoints: ['./src/cli.ts'],
outfile: 'dist/cli.js',
bundle,
minify,
platform,
sourcemap,
target,
plugins,
})
// eslint-disable-next-line unicorn/no-process-exit
.catch(() => process.exit(1));