build: add Vite web production pipeline
This commit is contained in:
34
frontend/scripts/copy-runtime-assets.js
Normal file
34
frontend/scripts/copy-runtime-assets.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import { copyFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const frontendRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const outputDirectory = path.join(frontendRoot, 'dist');
|
||||
|
||||
mkdirSync(outputDirectory, { recursive: true });
|
||||
|
||||
function copyEntry(source, destination) {
|
||||
const entries = readdirSync(source, { withFileTypes: true });
|
||||
mkdirSync(destination, { recursive: true });
|
||||
for (const entry of entries) {
|
||||
const sourcePath = path.join(source, entry.name);
|
||||
const destinationPath = path.join(destination, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
copyEntry(sourcePath, destinationPath);
|
||||
} else if (entry.isFile()) {
|
||||
copyFileSync(sourcePath, destinationPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of ['libs', 'favicon.ico']) {
|
||||
const source = path.join(frontendRoot, entry);
|
||||
if (existsSync(source)) {
|
||||
const destination = path.join(outputDirectory, entry);
|
||||
if (entry.includes('.')) {
|
||||
copyFileSync(source, destination);
|
||||
} else {
|
||||
copyEntry(source, destination);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user