chore(build): remove unused CSS processing plugins from esbuild config

This commit is contained in:
Quorafind 2025-12-03 07:49:50 +08:00
parent 0e0c1d6463
commit e0b6d079b5

View file

@ -20,48 +20,6 @@ if you want to view the source, please visit the github repository of this plugi
*/
`;
// Custom plugin to add CSS settings comment at the top of the CSS file
const cssSettingsPlugin = {
name: "css-settings-plugin",
setup(build) {
build.onEnd(async (result) => {
// Path to the output CSS file
const cssOutfile = "styles.css";
// The settings comment to prepend
const settingsComment =
fs.readFileSync("src/styles/index.css", "utf8").split("*/")[0] +
"*/\n\n";
if (fs.existsSync(cssOutfile)) {
// Read the current content
const cssContent = fs.readFileSync(cssOutfile, "utf8");
// Check if the settings comment is already there
if (!cssContent.includes("/* @settings")) {
// Prepend the settings comment
fs.writeFileSync(cssOutfile, settingsComment + cssContent);
}
}
});
},
};
const renamePlugin = {
name: "rename-styles",
setup(build) {
build.onEnd(() => {
const { outfile } = build.initialOptions;
const outcss = outfile.replace(/\.js$/, ".css");
const fixcss = outfile.replace(/main\.js$/, "styles.css");
if (fs.existsSync(outcss)) {
console.log("Renaming", outcss, "to", fixcss);
fs.renameSync(outcss, fixcss);
}
});
},
};
const prod = process.argv[2] === "production";
const outDir = prod ? "dist" : ".";
@ -121,7 +79,7 @@ const copyManifestPlugin = {
if (prod) {
fs.copyFileSync(
"manifest.json",
path.join(outDir, "manifest.json")
path.join(outDir, "manifest.json"),
);
console.log("Copied manifest.json to", outDir);
}