-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
51 lines (49 loc) · 1.2 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
45
46
47
48
49
50
51
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const webpack = require("webpack");
const dotenv = require("dotenv");
dotenv.config();
module.exports = (env, argv) => {
const prod = argv.mode === "production";
return {
mode: prod ? "production" : "development",
devtool: prod ? "hidden-source-map" : "eval",
entry: "./src/index.tsx",
output: {
path: path.join(__dirname, "/build"),
filename: "[name].js",
publicPath: "/",
},
devServer: {
port: 3000,
hot: true,
historyApiFallback: true,
},
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
loader: "file-loader",
},
{
test: /\.tsx?$/,
use: ["babel-loader", "ts-loader"],
},
],
},
plugins: [
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env),
}),
new webpack.ProvidePlugin({
React: "react",
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
],
};
};