vibetunnel/web/scripts/monaco-plugin.js
Mario Zechner f71b6d4bd7 feat: Create test infrastructure for component testing
- Rename terminal test bundle to generic test bundle (test.js)
- Create organized test structure in src/client/test/
- Move test HTML files to src/client/assets/test/
- Fix terminal-test component API usage and styling
- Fix Monaco editor worker loading issues by disabling workers
- Use AMD loader approach for Monaco initialization
- Apply Tailwind classes instead of inline CSS

The test infrastructure now supports isolated component testing with
individual HTML pages for each component. Monaco editor works with
syntax highlighting using the default vs-dark theme.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-23 04:25:56 +02:00

67 lines
No EOL
2 KiB
JavaScript

/**
* ESBuild plugin for Monaco Editor
*
* This plugin handles bundling Monaco Editor with proper worker configuration
*/
const fs = require('fs');
const path = require('path');
module.exports = {
monacoPlugin: {
name: 'monaco-editor',
setup(build) {
// Copy Monaco editor files to public directory
build.onStart(() => {
const monacoPath = path.join(__dirname, '../node_modules/monaco-editor/min');
const targetPath = path.join(__dirname, '../public/monaco-editor');
// Ensure target directory exists
if (!fs.existsSync(targetPath)) {
fs.mkdirSync(targetPath, { recursive: true });
}
// Copy vs directory (contains workers and other assets)
const vsSource = path.join(monacoPath, 'vs');
const vsTarget = path.join(targetPath, 'vs');
copyDirectorySync(vsSource, vsTarget);
// No need to copy worker files separately - they'll be loaded via AMD from the vs directory
console.log('Monaco Editor assets and workers copied to public/monaco-editor');
});
// Handle monaco-editor imports - use the full main entry
build.onResolve({ filter: /^monaco-editor$/ }, (args) => {
return {
path: require.resolve('monaco-editor/esm/vs/editor/editor.main.js'),
external: false,
};
});
},
},
};
function copyDirectorySync(src, dest) {
// Create destination directory if it doesn't exist
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}
// Read all items in source directory
const items = fs.readdirSync(src);
items.forEach(item => {
const srcPath = path.join(src, item);
const destPath = path.join(dest, item);
const stat = fs.statSync(srcPath);
if (stat.isDirectory()) {
// Recursively copy subdirectories
copyDirectorySync(srcPath, destPath);
} else {
// Copy file
fs.copyFileSync(srcPath, destPath);
}
});
}