-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
60 lines (58 loc) · 1.64 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
const esbuild = require('esbuild');
const { nodeExternalsPlugin } = require('esbuild-node-externals');
const { dependencies, peerDependencies } = require('./package.json');
const react18Plugin = require('esbuild-plugin-react18');
const esbuildPluginTsc = require('esbuild-plugin-tsc');
const CssModulesPlugin = require('esbuild-css-modules-plugin');
esbuild
.build({
entryPoints: ['src/index.ts'],
outdir: 'dist',
bundle: true,
minify: true,
treeShaking: true,
// sourcemap: true,
format: 'cjs',
target: ['es6'],
loader: {
'.module.css': 'local-css',
},
plugins: [
CssModulesPlugin({
// @see https://github.com/indooorsman/esbuild-css-modules-plugin/blob/main/index.d.ts for more details
force: false,
// emitDeclarationFile: true,
// localsConvention: 'camelCase',
// namedExports: true,
// inject: true,
}),
nodeExternalsPlugin(),
react18Plugin(),
// esbuildPluginTsc({ tsx: true }),
],
external: [].concat.apply(
[],
[Object.keys(dependencies || {}), Object.keys(peerDependencies || {})]
),
})
.then(async (result) => {
console.log('Build complete');
})
.catch((e) => {
console.error(e);
process.exit(1);
});
// const { nodeExternalsPlugin } = require("esbuild-node-externals");
// esbuild
// .build({
// entryPoints: ["./src/index.ts"],
// outfile: "dist/index.js",
// bundle: true,
// minify: true,
// treeShaking: true,
// platform: "node",
// format: "cjs",
// target: "node14",
// plugins: [nodeExternalsPlugin()],
// })
// .catch(() => process.exit(1));