Normalize SCSS manifest entries to CSS
This commit is contained in:
+5
-7
@@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node
|
|||||||
import { basename, dirname, extname, join, relative, resolve } from 'node:path';
|
import { basename, dirname, extname, join, relative, resolve } from 'node:path';
|
||||||
import { collectEntries, normalizePath, shouldCopyFile, walkFiles } from './file-rules.js';
|
import { collectEntries, normalizePath, shouldCopyFile, walkFiles } from './file-rules.js';
|
||||||
|
|
||||||
const addScssManifestAliases = (outDir) => {
|
const normalizeScssManifestEntries = (outDir) => {
|
||||||
const manifestPath = join(outDir, 'manifest.json');
|
const manifestPath = join(outDir, 'manifest.json');
|
||||||
|
|
||||||
if (!existsSync(manifestPath)) {
|
if (!existsSync(manifestPath)) {
|
||||||
@@ -19,16 +19,14 @@ const addScssManifestAliases = (outDir) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cssKey = `${key.slice(0, -'.scss'.length)}.css`;
|
const cssKey = `${key.slice(0, -'.scss'.length)}.css`;
|
||||||
if (manifest[cssKey]) {
|
manifest[cssKey] = manifest[cssKey] ?? {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
manifest[cssKey] = {
|
|
||||||
...entry,
|
...entry,
|
||||||
src: cssKey,
|
src: cssKey,
|
||||||
name: cssKey,
|
name: cssKey,
|
||||||
names: Array.isArray(entry.names) ? Array.from(new Set([cssKey, ...entry.names])) : [cssKey]
|
names: Array.isArray(entry.names) ? Array.from(new Set([cssKey, ...entry.names])) : [cssKey]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
delete manifest[key];
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +58,7 @@ const copyServerFilesPlugin = ({ sourceDir, outDir }) => ({
|
|||||||
cpSync(absolutePath, destination);
|
cpSync(absolutePath, destination);
|
||||||
});
|
});
|
||||||
|
|
||||||
addScssManifestAliases(outDir);
|
normalizeScssManifestEntries(outDir);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user