summaryrefslogtreecommitdiffstats
path: root/webpack.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webpack.config.ts')
-rw-r--r--webpack.config.ts51
1 files changed, 51 insertions, 0 deletions
diff --git a/webpack.config.ts b/webpack.config.ts
new file mode 100644
index 0000000..9ba1cd7
--- /dev/null
+++ b/webpack.config.ts
@@ -0,0 +1,51 @@
+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,
+ },
+};