-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
37 lines (33 loc) · 1.04 KB
/
Copy pathbuild.js
File metadata and controls
37 lines (33 loc) · 1.04 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
if(process.env.NODE_ENV === undefined) throw new Error("NODE_ENV not set");
const esbuild = require('esbuild');
const fs = require('fs');
const path = require('path');
// Read version from package.json
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const version = packageJson.version;
const isDev = process.env.NODE_ENV === 'development';
// Build options
const buildOptions = {
entryPoints: ['src/predbat-card.ts'],
bundle: true,
outfile: 'dist/Predbat-Table-Card-Next.js',
format: 'esm',
target: ['es2020'],
define: {
'process.env.PREDBAT_VERSION': JSON.stringify(version),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
},
banner: {
js: `// Predbat Table Card v${version}\n`
},
minify: !isDev,
sourcemap: true,
external: ['lit', '@lit', 'zod', 'home-assistant-js-websocket'],
logLevel: 'info'
};
// Build
esbuild.build(buildOptions)
.catch((error) => {
console.error('❌ Build failed:', error);
process.exit(1);
});