-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.mjs
59 lines (57 loc) · 1.66 KB
/
webpack.dev.mjs
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
50
51
52
53
54
55
56
57
58
59
// https://github.com/webpack/webpack/issues/1403#issuecomment-799346606
import HtmlWebpackPlugin from "html-webpack-plugin";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
// https://stackoverflow.com/a/50052194/7435656
const __dirname = dirname(fileURLToPath(import.meta.url));
export default {
/**
* https://webpack.js.org/guides/development/#using-webpack-dev-server
* Note: If using Express, consider webpack-dev-middleware instead
* https://webpack.js.org/guides/development/#using-webpack-dev-middleware
*/
devServer: {
contentBase: "./build",
port: 3000, // https://webpack.js.org/configuration/dev-server/
},
devtool: "inline-source-map", // https://webpack.js.org/guides/typescript/#source-maps
entry: "./app/index.tsx",
mode: "development", // https://webpack.js.org/guides/development/
module: {
rules: [
// https://webpack.js.org/guides/asset-management/
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/resource",
},
// https://webpack.js.org/guides/typescript/
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
// https://webpack.js.org/guides/output-management/
output: {
filename: "[name].bundle.js",
path: resolve(__dirname, "build"),
clean: true,
},
plugins: [
new HtmlWebpackPlugin({
template: "./app/index.html",
}),
],
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
};