-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpackage.core.js
More file actions
32 lines (29 loc) · 825 Bytes
/
Copy pathpackage.core.js
File metadata and controls
32 lines (29 loc) · 825 Bytes
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
const fs = require('fs');
let processEnv = {
name: 'processEnv',
setup(build){
build.onLoad({ filter:/.*/ }, async (args) => {
let contents = await fs.promises.readFile(args.path, 'utf8')
//Uncomment next line to list file paths
// console.log(args.path,contents.length)
const re1 = /process\.env/g;
const re2 = /process\.stderr/g;
contents = contents.replace(re1, 'import.meta.env');
contents = contents.replace(re2, 'import.meta.stderr');
return { contents }
})
}
}
require('esbuild').build({
entryPoints: ['src/Core/Core.js'],
format: 'esm',
bundle: true,
minify: true,
// watch: true,
define: {
global:"window",
},
external: ['math-expressions'],
plugins: [processEnv],
outfile: 'src/Viewer/core.js',
}).catch(() => process.exit(1))