-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
99 lines (96 loc) · 2.24 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const fs = require('fs');
require('dotenv').config();
const isProd = process.env.NODE_ENV == 'production';
module.exports = {
mode: !isProd ? 'development' : 'production',
devtool: !isProd ? 'source-map' : false,
entry: './src/index.tsx',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
publicPath: process.env.PUBLIC_PATH || '/',
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
port: 9000,
...(process.env.DEV_HTTPS_HOST && {
server: {
type: 'https',
options: {
key: fs.readFileSync(path.resolve(process.env.DEV_PATH_KEY)),
cert: fs.readFileSync(path.resolve(process.env.DEV_PATH_CERT)),
},
},
host: process.env.DEV_HTTPS_HOST,
}),
},
plugins: [
new CopyPlugin({
patterns: [
{
from: 'public',
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
new HtmlWebpackPlugin({
template: 'public/index.html',
}),
new webpack.DefinePlugin({
'process.env.PUBLIC_PATH': JSON.stringify(process.env.PUBLIC_PATH),
'process.env.TELEGRAM_BOT_NAME': JSON.stringify(
process.env.TELEGRAM_BOT_NAME,
),
}),
],
module: {
rules: [
{
test: /\.(ts|tsx)$/i,
loader: 'ts-loader',
exclude: ['/node_modules/'],
},
{
test: /\.module\.css$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
{
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: {
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'removeViewBox',
active: false,
},
],
},
},
},
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};