import path from "path"; import HtmlWebpackPlugin from "html-webpack-plugin"; import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"; import dotenv from "dotenv"; dotenv.config(); const absolutePath = (relativePath: string) => path.resolve(__dirname, relativePath); module.exports = { mode: process.env.MODE, entry: "src/index.ts", module: { rules: [ { test: /\.ts$/, include: [absolutePath("src")], use: "ts-loader", }, { test: /\.js$/, enforce: "pre", use: "source-map-loader", }, ], }, resolve: { extensions: [".ts", "..."], plugins: [new TsconfigPathsPlugin()], }, devtool: process.env.MODE === "development" ? "eval-cheap-module-source-map" : undefined, output: { filename: "bundle.js", path: absolutePath("dist"), }, plugins: [ new HtmlWebpackPlugin({ template: "src/index.html", staticPath: "static", }), ], devServer: { contentBase: absolutePath("dist"), compress: true, port: 8000, }, };