-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.js
25 lines (21 loc) · 808 Bytes
/
build.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
const path = require('path');
const fs = require('fs');
fs.mkdirSync(path.resolve(__dirname, 'dist/browser'), { recursive: true });
fs.mkdirSync(path.resolve(__dirname, 'dist/node'), { recursive: true });
fs.copyFileSync(
path.resolve(__dirname, 'libs/chacha20poly1305.js'),
path.resolve(__dirname, 'dist/browser/chacha20poly1305.js')
);
fs.copyFileSync(
path.resolve(__dirname, 'libs/chacha20poly1305.js'),
path.resolve(__dirname, 'dist/node/chacha20poly1305.js')
);
var script = fs.readFileSync(
path.resolve(__dirname, 'dist/browser/netcode.js')
);
script += `
var {aead_encrypt,aead_decrypt,getRandomBytes}=require('./chacha20poly1305');
`;
var entryFile = path.resolve(__dirname, 'dist/node/netcode.js');
fs.writeFileSync(entryFile, script);
console.log('successfully export', entryFile);