mirror of
https://github.com/unraid/api.git
synced 2026-01-07 09:10:05 -06:00
refactor: enhance CSS content retrieval in Vite config
- Updated the CSS content retrieval logic in `vite.standalone.config.ts` to dynamically find and read entry CSS files from specified directories, improving flexibility and maintainability. - Removed hardcoded CSS file paths in favor of a directory-based approach, allowing for easier updates and better organization of CSS assets.
This commit is contained in:
@@ -5,17 +5,23 @@ import fs from 'fs';
|
||||
|
||||
// Read CSS content at build time
|
||||
const getCssContent = () => {
|
||||
const cssFiles = [
|
||||
'.nuxt/dist/client/_nuxt/entry.DXd6OtrS.css',
|
||||
'.output/public/_nuxt/entry.DXd6OtrS.css',
|
||||
'assets/main.css'
|
||||
const directories = [
|
||||
'.nuxt/dist/client/_nuxt',
|
||||
'.output/public/_nuxt'
|
||||
];
|
||||
|
||||
for (const file of cssFiles) {
|
||||
const fullPath = path.resolve(__dirname, file);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
console.log(`Reading CSS from: ${fullPath}`);
|
||||
return fs.readFileSync(fullPath, 'utf-8');
|
||||
for (const dir of directories) {
|
||||
const fullDir = path.resolve(__dirname, dir);
|
||||
if (fs.existsSync(fullDir)) {
|
||||
// Find entry.*.css files dynamically
|
||||
const files = fs.readdirSync(fullDir);
|
||||
const entryFile = files.find(f => f.startsWith('entry.') && f.endsWith('.css'));
|
||||
|
||||
if (entryFile) {
|
||||
const fullPath = path.join(fullDir, entryFile);
|
||||
console.log(`Reading CSS from: ${fullPath}`);
|
||||
return fs.readFileSync(fullPath, 'utf-8');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user