-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.production.js
70 lines (69 loc) · 1.62 KB
/
webpack.config.production.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
mode: "production",
entry: {
main: path.join(__dirname, "src/index.tsx"),
},
output: {
path: path.resolve(__dirname, "build"),
filename: "[name]-[hash].js",
publicPath: "/",
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: ["babel-loader"],
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: { sourceMap: true },
},
],
},
{
test: /\.(jpe?g|png|gif|svg)$/,
use: [
{
loader: "url-loader",
options: { name: "[name]-[hash].[ext]", limit: 10000 },
},
],
},
{
test: /\.(woff2?|eot|ttf|otf)$/,
use: [
{
loader: "file-loader",
options: { name: "[name]-[hash].[ext]" },
},
],
},
],
},
resolve: {
modules: [path.join(__dirname, "src"), "node_modules"],
extensions: ["*", ".ts", ".tsx", ".css"],
},
plugins: [
new HtmlWebpackPlugin({
title: "React Boilerplate",
template: path.join(__dirname, "src/index.html"),
favicon: path.join(__dirname, "src/favicon.png"),
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
API_URL: JSON.stringify("https://api.domain.com"),
},
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
],
};