diff --git a/src/js/build.js b/src/js/build.js index 07b96e8..f600808 100644 --- a/src/js/build.js +++ b/src/js/build.js @@ -399,87 +399,6 @@ function copyTypeScriptFiles() { } } -// Copy node_modules folder -function copyNodeModules() { - console.log('Copying node_modules folder...'); - - if (!fs.existsSync('node_modules')) { - console.warn('⚠️ node_modules folder not found in root directory, skipping...'); - return; - } - - try { - const targetDir = path.join('public', 'node_modules'); - - // Create the target directory - if (!fs.existsSync(targetDir)) { - fs.mkdirSync(targetDir, { recursive: true }); - } - - // Use a more efficient approach to copy the directory - console.log('Starting node_modules copy (this may take a while)...'); - - // Use recursive directory copy with shell command if available - const { exec } = require('child_process'); - const isWindows = process.platform === 'win32'; - - if (isWindows) { - exec('xcopy node_modules public\\node_modules /E /I /H /Y', (error) => { - if (error) { - console.error('Error using xcopy for node_modules:', error); - copyNodeModulesManually(); - } else { - console.log('✓ Copied node_modules directory using xcopy'); - } - }); - } else { - exec('cp -R node_modules public/', (error) => { - if (error) { - console.error('Error using cp for node_modules:', error); - copyNodeModulesManually(); - } else { - console.log('✓ Copied node_modules directory using cp'); - } - }); - } - } catch (err) { - console.error('Error copying node_modules folder:', err); - } -} - -// Fall back to manual copy if shell commands fail -function copyNodeModulesManually() { - console.log('Falling back to manual node_modules copy (this will be slower)...'); - - function copyFolderRecursiveSync(source, target) { - // Check if folder needs to be created or integrated - const targetFolder = path.join(target, path.basename(source)); - if (!fs.existsSync(targetFolder)) { - fs.mkdirSync(targetFolder, { recursive: true }); - } - - // Copy - if (fs.lstatSync(source).isDirectory()) { - const files = fs.readdirSync(source); - files.forEach(function (file) { - const curSource = path.join(source, file); - if (fs.lstatSync(curSource).isDirectory()) { - copyFolderRecursiveSync(curSource, targetFolder); - } else { - fs.copyFileSync(curSource, path.join(targetFolder, file)); - } - }); - } - } - - try { - copyFolderRecursiveSync('node_modules', 'public'); - console.log('✓ Copied node_modules directory manually'); - } catch (err) { - console.error('Error in manual node_modules copy:', err); - } -} - // Update all file references in all files /* function updateAllReferences() { @@ -591,7 +510,6 @@ async function build() { console.log('Starting build process...'); cleanPublicDir(); - copyNodeModules(); // Run specific app.js debugging and minification await debugAppJsMinification();