mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(skin): add audio skins for HTML and React presets (#772)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
038ad8b4f5
commit
d751fdabea
@@ -0,0 +1,27 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
|
||||
/**
|
||||
* Resolves `@import` directives in CSS content, inlining referenced files.
|
||||
*
|
||||
* @param {string} content - The CSS content to resolve.
|
||||
* @param {string} baseDir - The directory to resolve relative imports from.
|
||||
* @param {string} skinsDir - The directory to resolve `@videojs/skins` imports from.
|
||||
* @returns {string} The resolved CSS content.
|
||||
*/
|
||||
export function resolveImports(content, baseDir, skinsDir) {
|
||||
return content.replace(/@import\s+['"]([^'"]+)['"]\s*;/g, (_, importPath) => {
|
||||
let file;
|
||||
|
||||
if (importPath.startsWith('@videojs/skins/')) {
|
||||
file = resolve(skinsDir, importPath.replace('@videojs/skins/', ''));
|
||||
} else if (importPath.startsWith('.')) {
|
||||
file = resolve(baseDir, importPath);
|
||||
} else {
|
||||
return _;
|
||||
}
|
||||
|
||||
const nested = readFileSync(file, 'utf-8');
|
||||
return resolveImports(nested, dirname(file), skinsDir);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user