mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-31 01:42:27 +00:00
fix(ci): fix netlify deployment by building to dist
- Move from root publishing to clean `dist/` directory - Create `scripts/build-dist.mjs` to orchestrate build and copy assets - Update `package.json` build script - Update `netlify.toml` to publish `dist/` - Ignore `dist/` in `.gitignore` Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
ccb60c3a7e
commit
0bfa3b08e8
638 files changed
+193490
-2
No files matched your search
@@ -0,0 +1,85 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const DIST = 'dist';
|
||||
const FILES_TO_COPY = [
|
||||
'index.html',
|
||||
'embed.html',
|
||||
'_redirects',
|
||||
'_headers',
|
||||
'site.webmanifest',
|
||||
'sw.min.js'
|
||||
];
|
||||
const DIRS_TO_COPY = [
|
||||
'assets',
|
||||
'bitvid_logo',
|
||||
'components',
|
||||
'config',
|
||||
'content',
|
||||
'css',
|
||||
'docs',
|
||||
'examples',
|
||||
'js',
|
||||
'releases',
|
||||
'torrent',
|
||||
'vendor',
|
||||
'views'
|
||||
];
|
||||
|
||||
function cleanDist() {
|
||||
if (fs.existsSync(DIST)) {
|
||||
fs.rmSync(DIST, { recursive: true, force: true });
|
||||
}
|
||||
fs.mkdirSync(DIST);
|
||||
}
|
||||
|
||||
function copyFile(src, dest) {
|
||||
if (fs.existsSync(src)) {
|
||||
fs.copyFileSync(src, dest);
|
||||
} else {
|
||||
console.warn(`Warning: Source file ${src} does not exist.`);
|
||||
}
|
||||
}
|
||||
|
||||
function copyDir(src, dest) {
|
||||
if (!fs.existsSync(src)) return;
|
||||
fs.mkdirSync(dest, { recursive: true });
|
||||
const entries = fs.readdirSync(src, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copyDir(srcPath, destPath);
|
||||
} else {
|
||||
copyFile(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
console.log('Cleaning dist...');
|
||||
cleanDist();
|
||||
|
||||
console.log('Running build:css...');
|
||||
try {
|
||||
execSync('npm run build:css', { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.error('Failed to run build:css');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('Copying files...');
|
||||
for (const file of FILES_TO_COPY) {
|
||||
copyFile(file, path.join(DIST, file));
|
||||
}
|
||||
|
||||
console.log('Copying directories...');
|
||||
for (const dir of DIRS_TO_COPY) {
|
||||
copyDir(dir, path.join(DIST, dir));
|
||||
}
|
||||
|
||||
console.log('Build complete.');
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in new issue
Block a user