mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-08-06 13:55:15 +03:00
feat: Introduce fe modular build system
This commit is contained in:
35
fe-app-podkop/tsup.config.ts
Normal file
35
fe-app-podkop/tsup.config.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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}`);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user