Skip to content

Commit 38a4f9a

Browse files
Add CSS sourcemap placeholders for dev outputs
Avoid 404s on *.css.map when using external source maps by generating minimal placeholder maps alongside popup.css and content-script.css for Chromium and Firefox dev builds. No impact on production artifacts
1 parent 0fdeae8 commit 38a4f9a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

build.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ async function finishOutput(outputDirSuffix, sourceBuildDir = outdir) {
501501
[...commonFiles, { src: 'src/manifest.json', dst: 'manifest.json' }],
502502
chromiumOutputDir,
503503
)
504-
// In development, ensure placeholder CSS files exist to avoid 404 noise
504+
// In development, ensure placeholder CSS and CSS sourcemap files exist to avoid 404 noise
505505
if (!isProduction) {
506506
const chromiumCssPlaceholders = [
507507
path.join(chromiumOutputDir, 'popup.css'),
@@ -511,6 +511,10 @@ async function finishOutput(outputDirSuffix, sourceBuildDir = outdir) {
511511
if (!(await fs.pathExists(p))) {
512512
await fs.outputFile(p, '/* dev placeholder */\n')
513513
}
514+
const mapPath = `${p}.map`
515+
if (!(await fs.pathExists(mapPath))) {
516+
await fs.outputFile(mapPath, '{"version":3,"sources":[],"mappings":"","names":[]}')
517+
}
514518
}
515519
}
516520
if (isProduction) await zipFolder(chromiumOutputDir)
@@ -521,7 +525,7 @@ async function finishOutput(outputDirSuffix, sourceBuildDir = outdir) {
521525
[...commonFiles, { src: 'src/manifest.v2.json', dst: 'manifest.json' }],
522526
firefoxOutputDir,
523527
)
524-
// In development, ensure placeholder CSS files exist to avoid 404 noise
528+
// In development, ensure placeholder CSS and CSS sourcemap files exist to avoid 404 noise
525529
if (!isProduction) {
526530
const firefoxCssPlaceholders = [
527531
path.join(firefoxOutputDir, 'popup.css'),
@@ -531,6 +535,10 @@ async function finishOutput(outputDirSuffix, sourceBuildDir = outdir) {
531535
if (!(await fs.pathExists(p))) {
532536
await fs.outputFile(p, '/* dev placeholder */\n')
533537
}
538+
const mapPath = `${p}.map`
539+
if (!(await fs.pathExists(mapPath))) {
540+
await fs.outputFile(mapPath, '{"version":3,"sources":[],"mappings":"","names":[]}')
541+
}
534542
}
535543
}
536544
if (isProduction) await zipFolder(firefoxOutputDir)

0 commit comments

Comments
 (0)