diff options
| author | Maksymilian Jopek <maks@jopek.eu> | 2021-10-14 23:32:50 +0200 |
|---|---|---|
| committer | Maksymilian Jopek <maks@jopek.eu> | 2021-10-14 23:32:50 +0200 |
| commit | 94ca5987544009f2da17fe27abc6c9de380d34fd (patch) | |
| tree | 5b35293f5d9c76a8e953b5d04391aed15e9fb24d /webpack.config.ts | |
| download | isiqandisi-94ca5987544009f2da17fe27abc6c9de380d34fd.tar.gz isiqandisi-94ca5987544009f2da17fe27abc6c9de380d34fd.tar.zst isiqandisi-94ca5987544009f2da17fe27abc6c9de380d34fd.zip | |
Initial commit - config with index.hmtl
Diffstat (limited to 'webpack.config.ts')
| -rw-r--r-- | webpack.config.ts | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/webpack.config.ts b/webpack.config.ts new file mode 100644 index 0000000..5d4e95f --- /dev/null +++ b/webpack.config.ts @@ -0,0 +1,73 @@ +import path from "path"; +import HtmlWebpackPlugin from "html-webpack-plugin"; +import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"; +import MiniCssExtractPlugin from "mini-css-extract-plugin"; +import dotenv from "dotenv"; + +dotenv.config(); + +const absolutePath = (relativePath: string) => + path.resolve(__dirname, relativePath); + +module.exports = { + mode: process.env.MODE, + entry: { + index: "src/index.ts", + main: "src/main.ts" + }, + output: { + filename: "[name].js", + path: absolutePath("dist"), + }, + module: { + rules: [ + { + test: /\.ts$/, + include: [absolutePath("src")], + use: "ts-loader", + }, + { + test: /\.js$/, + enforce: "pre", + use: "source-map-loader", + }, + { + test: /\.css$/, + use: [MiniCssExtractPlugin.loader, "css-loader"], + }, + ], + }, + resolve: { + extensions: [".ts", "..."], + plugins: [new TsconfigPathsPlugin()], + }, + devtool: + process.env.MODE === "development" + ? "eval-cheap-module-source-map" + : undefined, + plugins: [ + new HtmlWebpackPlugin({ + template: "src/templates/index.html", + favicon: "static/favicon.ico", + filelename: "index.html", + showErrors: true, + excludeChunks: ["main"], + }), + new HtmlWebpackPlugin({ + template: "src/templates/main.html", + favicon: "static/favicon.ico", + filename: "main.html", + showErrors: true, + excludeChunks: ["index"], + }), + new MiniCssExtractPlugin(), + ], + node: { + global: true, + }, + devServer: { + contentBase: absolutePath("static"), + compress: true, + port: 8000, + }, +}; |
