const CopyPlugin = require("copy-webpack-plugin");
const path = require("path");

module.exports = {
	context: path.resolve(__dirname, ".."),
	entry: {
		index: "./src/background/index4Firefox.ts",
		tabScript: "./src/tabScript/index4Firefox.ts",
	},
	devtool: "inline-source-map",
	output: {
		filename: "[name].js",
		path: path.resolve(__dirname, "../dist/firefox"),
	},
	resolve: {
		extensions: [".js", ".tsx", ".ts"],
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				use: [{ loader: "style-loader" }, { loader: "css-loader" }],
			},
			{
				test: /\.tsx?$/,
				use: "ts-loader",
				exclude: /node_modules/,
			},
		],
	},
	plugins: [
		new CopyPlugin([
			{ from: "./src/manifest.firefox.json", to: "manifest.json" },
			{ from: "./src/images/plugin_icon.png", to: "images/plugin_icon.png" },
			{
				from: "./src/images/plugin_icon_blue.png",
				to: "images/plugin_icon_blue.png",
			},
			{
				from: "./src/images/plugin_icon_red.png",
				to: "images/plugin_icon_red.png",
			},
			{
				from: "./src/images/plugin_icon_green.png",
				to: "images/plugin_icon_green.png",
			},
			{ from: "./src/popup/", to: "popup" },
		]),
	],
};
