-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.config.ts
96 lines (92 loc) · 2.92 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
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
const path = require('path');
const webpack = require('webpack');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const dotenv = require('dotenv-webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const isDevelopment = process.env.NODE_ENV !== 'production';
const config = {
name: 'togetherfront',
mode: isDevelopment ? 'development' : 'production',
devtool: !isDevelopment ? 'hidden-source-map' : 'eval',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
alias: {
'@main': path.resolve(__dirname, 'src/components/Main'),
'@result': path.resolve(__dirname, 'src/components/Result'),
'@auth': path.resolve(__dirname, 'src/components/Auth'),
'@review': path.resolve(__dirname, 'src/components/Review'),
'@timeline': path.resolve(__dirname, 'src/components/Timeline'),
'@rotation': path.resolve(__dirname, 'src/components/Rotation'),
'@utils': path.resolve(__dirname, 'src/components/utils'),
'@recoil': path.resolve(__dirname, 'src/recoil'),
'@img': path.resolve(__dirname, 'src/assets/img'),
'@css': path.resolve(__dirname, 'src/assets/css'),
'@usefulObj': path.resolve(__dirname, 'src/assets/usefulObj'),
'@types': path.resolve(__dirname, 'src/assets/usefulObj/types'),
'@cert': path.resolve(__dirname, 'src/cert'),
'@globalObj': path.resolve(__dirname, 'src/globalObj'),
'@service': path.resolve(__dirname, 'src/service'),
},
},
entry: {
app: './src/client',
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: { browsers: ['last 2 chrome versions'] },
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
env: {
development: {
plugins: [require.resolve('react-refresh/babel')],
},
},
},
exclude: path.join(__dirname, 'node_modules'),
},
{
test: /\.(scss|css)?$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(svg|avif|webp|png|jpeg)$/i,
loader: 'file-loader',
},
{
test: /\.(woff|woff2|eot|ttf|otf|jpg)$/i,
loader: 'file-loader',
},
],
},
plugins: [
new webpack.EnvironmentPlugin({ NODE_ENV: isDevelopment ? 'development' : 'production' }),
new dotenv(),
new HtmlWebpackPlugin({
template: './src/index.html',
}),
],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
publicPath: '/',
},
devServer: {
historyApiFallback: true,
port: +process.env.FRONT_PORT || 3050,
},
};
if (isDevelopment && config.plugins) {
config.plugins.push(new ReactRefreshWebpackPlugin());
}
module.exports = config;