mirror of
https://github.com/Anarios/return-youtube-dislike.git
synced 2026-09-12 10:22:10 +02:00
40fda6dd32
* auth works * Works after review. * switched to auth flow * all works well in chrome * all works well in chrome and firefox * translations harmonized * translations harmonized * website translations * Translations harmonized. * Everything kinda works * Almost works * all works * all works * all works #2 * Streamline premium analytics range handling * Restore premium analytics selection flow * Fix analytics zoom interactions * Add per-section expansion controls to premium analytics * Adjust map legend visibility for premium analytics * Add missing country synonyms for premium map * Remove legacy premium badge overlay * Polish premium analytics controls for light theme * Refresh map legend when toggling sections * Improve light-mode styling for range selectors * Fix map mode switching regression * Fix for panel expand * Typo fix * webpack fix * before next steps. * split, zero-buckets * bucket size indicated on UI * all works * first/last toggle * breadcrumbs * release
137 lines
3.7 KiB
JavaScript
137 lines
3.7 KiB
JavaScript
const path = require("path");
|
|
const fs = require("fs");
|
|
const CopyPlugin = require("copy-webpack-plugin");
|
|
|
|
const extensionVersion = process.env.npm_package_version.replace("-", ".");
|
|
const entries = ["ryd.content-script", "ryd.background", "popup", "ryd.changelog"];
|
|
|
|
const ignorePatterns = [
|
|
"**/manifest-**",
|
|
"**/dist/**",
|
|
"**/src/**",
|
|
"**/readme.md",
|
|
...entries.map((entry) => `**/${entry}.js`),
|
|
];
|
|
|
|
const manifestTransform = (content, filename) => {
|
|
const filteredContent = content
|
|
.toString()
|
|
.split("\n")
|
|
.filter((str) => !str.trimStart().startsWith("//"))
|
|
.join("\n");
|
|
|
|
const manifestData = JSON.parse(filteredContent);
|
|
manifestData.version = extensionVersion;
|
|
return JSON.stringify(manifestData, null, 2);
|
|
};
|
|
|
|
const i18nTransform = (content, filename) => {
|
|
if (!filename.endsWith("messages.json")) return content;
|
|
|
|
return content.toString().replace(/__RYD_VERSION__/g, extensionVersion);
|
|
};
|
|
|
|
class MirrorJsOutputsPlugin {
|
|
constructor(targetDirs) {
|
|
this.targetDirs = targetDirs;
|
|
}
|
|
|
|
apply(compiler) {
|
|
compiler.hooks.afterEmit.tapPromise("MirrorJsOutputsPlugin", async () => {
|
|
const { promises: fsp } = fs;
|
|
const outputPath = compiler.options.output.path;
|
|
const entries = await fsp.readdir(outputPath).catch(() => []);
|
|
const jsAssets = entries.filter((name) => name.endsWith(".js"));
|
|
|
|
await Promise.all(
|
|
this.targetDirs.map(async (dir) => {
|
|
const targetDir = path.join(outputPath, dir);
|
|
await fsp.mkdir(targetDir, { recursive: true });
|
|
|
|
const existingFiles = await fsp.readdir(targetDir).catch(() => []);
|
|
await Promise.all(
|
|
existingFiles
|
|
.filter((file) => file.endsWith(".js"))
|
|
.map((file) => fsp.rm(path.join(targetDir, file), { force: true }))
|
|
);
|
|
|
|
await Promise.all(
|
|
jsAssets.map((asset) =>
|
|
fsp.copyFile(path.join(outputPath, asset), path.join(targetDir, path.basename(asset))),
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
entry: Object.fromEntries(
|
|
entries.map((entry) => [entry, path.join(__dirname, "./Extensions/combined/", `${entry}.js`)]),
|
|
),
|
|
output: {
|
|
filename: "[name].js",
|
|
path: path.resolve(__dirname, "Extensions/combined/dist"),
|
|
clean: true,
|
|
},
|
|
cache: false,
|
|
optimization: {
|
|
minimize: false,
|
|
},
|
|
watchOptions: {
|
|
ignored: "**/dist/**",
|
|
},
|
|
plugins: [
|
|
// exclude locale files in moment
|
|
new CopyPlugin({
|
|
patterns: [
|
|
{
|
|
from: "./Extensions/combined",
|
|
to: "./chrome",
|
|
globOptions: {
|
|
ignore: ignorePatterns,
|
|
},
|
|
transform: i18nTransform,
|
|
},
|
|
{
|
|
from: "./Extensions/combined/manifest-chrome.json",
|
|
to: "./chrome/manifest.json",
|
|
transform: manifestTransform,
|
|
},
|
|
{
|
|
from: "./Extensions/combined",
|
|
to: "./firefox",
|
|
globOptions: {
|
|
ignore: ignorePatterns,
|
|
},
|
|
transform: i18nTransform,
|
|
},
|
|
{
|
|
from: "./Extensions/combined/manifest-firefox.json",
|
|
to: "./firefox/manifest.json",
|
|
transform: manifestTransform,
|
|
},
|
|
{
|
|
from: "./Extensions/combined",
|
|
to: "./safari",
|
|
globOptions: {
|
|
ignore: ignorePatterns,
|
|
},
|
|
transform: i18nTransform,
|
|
},
|
|
{
|
|
from: "./Extensions/combined/manifest-safari.json",
|
|
to: "./safari/manifest.json",
|
|
transform: manifestTransform,
|
|
},
|
|
],
|
|
}),
|
|
new MirrorJsOutputsPlugin(["chrome", "firefox", "safari"]),
|
|
],
|
|
experiments: {
|
|
topLevelAwait: true,
|
|
},
|
|
devtool: "inline-source-map",
|
|
};
|