-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.ts
49 lines (42 loc) · 1.01 KB
/
webpack.config.ts
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
45
46
47
48
49
import * as path from "path";
import * as webpack from "webpack";
import * as MiniCssExtract from "mini-css-extract-plugin";
import * as HtmlWebpackPlugin from "html-webpack-plugin";
const config: webpack.Configuration = {
mode: process.env.NODE_ENV === "prod" ? "production" : "development",
entry: path.resolve(__dirname, "src/index.ts"),
output: {
path: path.resolve("build"),
filename: "[name].[contenthash].js",
},
// plugins
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "public/index.html"),
}),
new MiniCssExtract(),
],
resolve: {
extensions: [".ts", ".tsx", ".js"],
},
// modules and loaders
module: {
rules: [
{
test: /\.tsx?$/,
use: ["ts-loader"],
},
{
test: /\.css$/,
use: [MiniCssExtract.loader, "css-loader"],
},
],
},
// dev server config
devServer: {
port: 3000,
contentBase: path.resolve(__dirname, "build"),
compress: true,
},
};
export default config;