const path = require("path");

const port = 3000;
const openBrowser = true;

module.exports = {
    entry: {
        app: ["./src/index.js"],
    },
    output: {
        filename: "bundle.js",
        path: path.resolve(__dirname, "public"),
        publicPath: "/",
    },
    mode: "development",
    devtool: "source-map",
    devServer: {
        port: port,
        open: openBrowser,
        historyApiFallback: {
            index: "index.html",
        },
        static: "public",
    },
    module: {
        rules: [
            {
                test: /\.s[ac]ss$/i,
                use: [
                    'style-loader',  // Injects styles into DOM
                    'css-loader',    // Resolves CSS imports
                    'sass-loader'    // Compiles Sass to CSS
                ],
            },
        ],
    },
};