/
webpack.config.js
44 lines (42 loc) 路 1.04 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const path = require("path");
const ESLintPlugin = require("eslint-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const isProduction = (mode) => mode === "production";
/** @return {import('webpack').Configuration} */
module.exports = (_, { mode }) => ({
mode,
entry: "./src/index.ts",
output: {
filename: "bundle.js",
path: path.join(__dirname, "dist"),
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: "ts-loader",
},
],
},
plugins: [
new ESLintPlugin(),
new Dotenv({
systemvars: true,
}),
new CopyPlugin({
patterns: [{ from: "public" }],
}),
new HtmlWebpackPlugin({
template: "index.html",
}),
new CleanWebpackPlugin(),
],
resolve: {
extensions: [".ts", ".js"],
},
devtool: isProduction(mode) ? false : "inline-source-map",
});