21 lines
906 B
JavaScript
21 lines
906 B
JavaScript
// Copy the original ES5 hls.min.js source directly to dist/hlds.js.
|
|
// This avoids Vite/esbuild adding arrow functions (which Chrome flags as "ES module content"
|
|
// in extension URLs, preventing window.Hls from registering).
|
|
|
|
import { readFileSync, writeFileSync } from 'fs';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, resolve } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const src = resolve(__dirname, '../src/inject/hls.min.js');
|
|
const dst = resolve(__dirname, '../dist/hlds.js');
|
|
let data = readFileSync(src, 'utf-8');
|
|
|
|
// Remove sourceMappingURL line (avoids Chrome trying to fetch it from an invalid chrome-extension:// URL)
|
|
data = data.replace(/[\r\n]+\/\/# sourceMappingURL=[^\s]*[\r\n]*/, '');
|
|
|
|
writeFileSync(dst, data);
|
|
console.log(`[copy-hlds] Copied hls.min.js -> dist/hlds.js (${data.length} bytes, pure ES5 source)`);
|