mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-29 08:52:25 +00:00
Fix Netlify build by restoring dist build script and config
- Restore `scripts/build-dist.mjs` to clean `dist/`, build CSS, and copy assets. - Update `package.json` to use the new build script and serve `dist`. - Update `netlify.toml` to publish the `dist` directory. - Update `dist/` artifacts to match current source. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
a432d3d4c0
commit
c862cbc358
72 files changed
+1555
-5883
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { exec } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
const FILES_TO_COPY = [
|
||||
'index.html',
|
||||
'embed.html',
|
||||
'site.webmanifest',
|
||||
'sw.min.js',
|
||||
'_headers',
|
||||
'_redirects',
|
||||
'assets',
|
||||
'bitvid_logo',
|
||||
'components',
|
||||
'config',
|
||||
'content',
|
||||
'css',
|
||||
'docs',
|
||||
'js',
|
||||
'torrent',
|
||||
'vendor',
|
||||
'views'
|
||||
];
|
||||
|
||||
async function build() {
|
||||
const distDir = 'dist';
|
||||
|
||||
console.log(`[build] Cleaning ${distDir}...`);
|
||||
await fs.rm(distDir, { recursive: true, force: true });
|
||||
await fs.mkdir(distDir, { recursive: true });
|
||||
|
||||
console.log('[build] Building CSS...');
|
||||
try {
|
||||
const { stdout, stderr } = await execAsync('npm run build:css');
|
||||
if (stdout) console.log(stdout);
|
||||
if (stderr) console.error(stderr);
|
||||
} catch (error) {
|
||||
console.error('[build] CSS build failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('[build] Copying files...');
|
||||
for (const item of FILES_TO_COPY) {
|
||||
const source = item;
|
||||
const destination = path.join(distDir, item);
|
||||
|
||||
try {
|
||||
// Check if source exists
|
||||
await fs.access(source);
|
||||
|
||||
console.log(` -> Copying ${source}`);
|
||||
await fs.cp(source, destination, { recursive: true });
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.warn(` [warn] Source file/directory not found: ${source}`);
|
||||
} else {
|
||||
console.error(` [error] Failed to copy ${source}:`, error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[build] Build complete!');
|
||||
}
|
||||
|
||||
build();
|
||||
Reference in new issue
Block a user