// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import path from "node:path";
import { fileURLToPath } from "node:url";
import CopyPlugin from "copy-webpack-plugin";

const dirName = fileURLToPath(new URL(".", import.meta.url));
const srcDir = path.join(dirName, "src");
export default {
    mode: "development",
    devtool: "inline-source-map",
    entry: {
        index: path.join(srcDir, "view", "site", "index.ts"),
    },
    output: {
        path: path.join(dirName, "dist", "view"),
        filename: "[name].js",
    },
    module: {
        rules: [
            {
                test: /\.tsx?$/,
                use: "ts-loader",
                exclude: /node_modules/,
            },
        ],
    },
    resolve: {
        extensions: [".tsx", ".ts", ".js"],
    },
    plugins: [
        new CopyPlugin({
            patterns: [
                {
                    from: path.join(srcDir, "view", "site", "index.html"),
                    to: "./site/",
                },
                {
                    from: path.join(srcDir, "view", "site", "styles.css"),
                    to: "./site/",
                },
            ],
        }),
    ],
};
