youfoundjk_TeXcore/esbuild.config.mjs
JK 16ca794de8 fix(equations): preserve LaTeX row-break dimensions in sub-equation tagging
- Update the sub-equation row split logic in live-preview-equations to use a capturing regex `/(\\\\(?:\s*\[[^\]]*\])?)/`.
- Reconstruct the equation parts by only tagging the math content and preserving the separators (e.g. `\\[0.6em]`) exactly as-is.
- Add unit tests verifying both standard and dimensioned row breaks.
2026-07-17 13:06:44 +02:00

112 lines
3.2 KiB
JavaScript

import esbuild from 'esbuild';
import process from 'process';
import { builtinModules } from 'node:module';
import fs from 'fs';
import path from 'path';
import inlineWorkerPlugin from 'esbuild-plugin-inline-worker';
const builtins = [
...new Set([...builtinModules, ...builtinModules.map(moduleName => `node:${moduleName}`)])
];
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
const prod = process.argv[2] === 'production';
async function build() {
const context = await esbuild.context({
banner: {
js: banner
},
entryPoints: ['src/main.ts'],
bundle: true,
plugins: [
inlineWorkerPlugin({ format: 'iife' }),
{
name: 'copy-to-dev-vault-plugin',
setup(build) {
build.onEnd(() => {
const rootDir = process.cwd();
const devEnvDir = path.join(
rootDir,
'../plugin-full-calendar/obsidian-dev-vault/.obsidian/plugins/TeXcore'
);
// Ensure dev output directory exists
try {
if (!fs.existsSync(devEnvDir)) {
fs.mkdirSync(devEnvDir, { recursive: true });
}
} catch (err) {
console.warn('⚠️ Could not create output directory:', err.message);
}
// Copy build files
try {
if (fs.existsSync(path.join(rootDir, 'main.js'))) {
fs.copyFileSync(path.join(rootDir, 'main.js'), path.join(devEnvDir, 'main.js'));
console.log(' | Copied main.js to dev vault');
}
if (fs.existsSync(path.join(rootDir, 'styles.css'))) {
fs.copyFileSync(
path.join(rootDir, 'styles.css'),
path.join(devEnvDir, 'styles.css')
);
console.log(' | Copied styles.css to dev vault');
}
if (fs.existsSync(path.join(rootDir, 'manifest.json'))) {
fs.copyFileSync(
path.join(rootDir, 'manifest.json'),
path.join(devEnvDir, 'manifest.json')
);
console.log(' | Copied manifest.json to dev vault');
}
} catch (err) {
console.warn('⚠️ Could not copy files to dev vault:', err.message);
}
});
}
}
],
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins
],
format: 'cjs',
target: 'es2020',
logLevel: 'info',
minify: prod,
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js'
});
if (!prod) {
await context.watch();
console.log('Watching for changes...');
} else {
await context.rebuild();
await context.dispose();
}
}
build().catch(err => {
console.error(err);
process.exit(1);
});