2021-12-22 21:58:20 +00:00
|
|
|
/* eslint-disable */
|
|
|
|
|
2022-01-02 13:51:46 +00:00
|
|
|
import { spawnSync } from 'child_process';
|
|
|
|
import { writeFileSync, readFileSync } from 'fs'
|
2021-12-22 21:58:20 +00:00
|
|
|
|
2022-01-02 13:51:46 +00:00
|
|
|
import esbuild from "esbuild";
|
|
|
|
import esbuildSvelte from "esbuild-svelte";
|
|
|
|
import sveltePreprocess from "svelte-preprocess";
|
2022-01-08 18:01:01 +00:00
|
|
|
import { extheader } from './extheader.js';
|
2022-01-02 13:51:46 +00:00
|
|
|
|
|
|
|
let res = spawnSync("git", ["rev-list", "--count", "HEAD"]);
|
2022-01-01 22:49:13 +00:00
|
|
|
let rev = +res.stdout;
|
2021-12-22 21:58:20 +00:00
|
|
|
|
|
|
|
(async () => {
|
2022-01-05 01:14:23 +00:00
|
|
|
let res;
|
2022-01-02 13:51:46 +00:00
|
|
|
|
|
|
|
res = await esbuild
|
|
|
|
.build({
|
|
|
|
entryPoints: ["src/main.ts"],
|
|
|
|
bundle: true,
|
|
|
|
outfile: "./dist/main.js",
|
|
|
|
define: {
|
|
|
|
global: 'window'
|
|
|
|
},
|
|
|
|
inject: ['./esbuild.inject.js'],
|
|
|
|
plugins: [
|
|
|
|
esbuildSvelte({
|
2022-01-07 06:45:30 +00:00
|
|
|
compilerOptions: { css: true, accessors: true },
|
2022-01-02 13:51:46 +00:00
|
|
|
preprocess: sveltePreprocess(),
|
|
|
|
})
|
|
|
|
],
|
2022-01-06 05:59:52 +00:00
|
|
|
loader: {
|
2022-01-12 05:31:58 +00:00
|
|
|
'.css': 'text',
|
|
|
|
'.png': 'binary'
|
2022-01-06 05:59:52 +00:00
|
|
|
},
|
2022-01-02 13:51:46 +00:00
|
|
|
metafile: true
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log(Object.entries(res.metafile.inputs).sort((a, b) => a[1].bytes - b[1].bytes).map(e => `${e[0]} -> ${e[1].bytes}`).join('\n'));
|
|
|
|
writeFileSync('./main.user.js', extheader + readFileSync('./dist/main.js'));
|
2022-01-02 15:32:29 +00:00
|
|
|
writeFileSync('./main.meta.js', extheader);
|
2021-12-22 21:58:20 +00:00
|
|
|
})();
|