diff options
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, + }, +}; |
