-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
96 lines (92 loc) · 2.38 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
const path = require('path');
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const dotenv = require('dotenv').config({
path: 'ui/.env'
})
const isDevelopment = process.env.NODE_ENV !== 'production';
const outputDir = 'ui/dist';
module.exports = {
mode: isDevelopment ? 'development' : 'production',
entry: {
main: './ui/src/index.tsx',
},
output: {
path: path.join(__dirname, outputDir),
filename: 'pibu.bundle.js?t=' + new Date().getTime(),
publicPath: '/',
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.graphql$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
{
test: /\.(tsx|ts)?$/,
include: path.join(__dirname, 'ui/src'),
use: [
isDevelopment && {
loader: 'babel-loader',
options: { plugins: ['react-refresh/babel'] },
},
{
loader: 'ts-loader',
options: {
transpileOnly: true,
configFile: "tsconfig.ui.json",
},
},
].filter(Boolean),
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
},
],
},
plugins: [
isDevelopment && new ReactRefreshPlugin(),
// isDevelopment && new webpack.HotModuleReplacementPlugin(),
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: 'tsconfig.ui.json'
}
}),
new HtmlWebpackPlugin({
filename: './index.html',
template: './ui/public/index.html',
}),
new webpack.DefinePlugin({
'process.env': JSON.stringify(dotenv.parsed)
}),
].filter(Boolean),
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
devServer: {
port: 3001,
host: '0.0.0.0',
hot: true,
https: true,
cert: "./nginx/certs/bundle.crt",
key: "./nginx/certs/bundle.key",
disableHostCheck: true, // for local /etc/hosts file
historyApiFallback: true
},
devtool: 'inline-source-map',
};