-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
51 lines (40 loc) · 1.21 KB
/
build.ts
File metadata and controls
51 lines (40 loc) · 1.21 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
/* eslint-env node */
import esbuild from 'esbuild';
import packageJson from './package.json';
const isProduction = process.env.NODE_ENV === 'production';
const scriptName = packageJson.name + (isProduction ? '' : '-dev');
const scriptVersion = isProduction ? packageJson.version : 'Beta';
const now = new Date();
const nowStr = `${now.toDateString()} ${now.toTimeString()}`;
const prodUrl = isProduction
? 'https://raw.githubusercontent.com/mbme/scraper/main/docs/scraper.user.js'
: '';
const banner = `
// ==UserScript==
// @name ${scriptName}
// @version ${scriptVersion}
// @description ${packageJson.description} Updated on ${nowStr}
// @author ${packageJson.author}
// @match *://*/*
// @grant GM_registerMenuCommand
// @updateURL ${prodUrl}
// @downloadURL ${prodUrl}
// ==/UserScript==
`;
await esbuild.build({
entryPoints: ['./src/index.ts'],
outfile: './dist/scraper.user.js',
banner: {
js: banner,
},
target: ['es2019'],
bundle: true,
minify: false, // ease of debugging is more important than size
sourcemap: true,
loader: {
'.html': 'text',
},
define: {
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"',
},
});