mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-06 11:36:50 +03:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { defineConfig } from 'tsup';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
entry: ['src/main.ts'],
|
|
format: ['esm'], // пусть tsup генерит export {...}
|
|
outDir: '../luci-app-podkop/htdocs/luci-static/resources/view/podkop',
|
|
outExtension: () => ({ js: '.js' }),
|
|
dts: false,
|
|
clean: false,
|
|
sourcemap: false,
|
|
banner: {
|
|
js: `// This file is autogenerated, please don't change manually \n"use strict";`,
|
|
},
|
|
esbuildOptions(options) {
|
|
options.legalComments = 'none';
|
|
},
|
|
onSuccess: () => {
|
|
const outDir =
|
|
'../luci-app-podkop/htdocs/luci-static/resources/view/podkop';
|
|
const file = path.join(outDir, 'main.js');
|
|
let code = fs.readFileSync(file, 'utf8');
|
|
|
|
code = code.replace(
|
|
/export\s*{([\s\S]*?)}/,
|
|
(match, group) => {
|
|
return `return baseclass.extend({${group}})`;
|
|
}
|
|
);
|
|
|
|
fs.writeFileSync(file, code, 'utf8');
|
|
console.log(`✅ Patched LuCI build: ${file}`);
|
|
},
|
|
});
|