forked from SigNoz/signoz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
115 lines (109 loc) · 2.34 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* eslint-disable @typescript-eslint/no-var-requires */
// shared config (dev and prod)
const { resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const portFinderSync = require('portfinder-sync');
const dotenv = require('dotenv');
const webpack = require('webpack');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
dotenv.config();
console.log(resolve(__dirname, './src/'));
const plugins = [
new HtmlWebpackPlugin({ template: 'src/index.html.ejs' }),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new webpack.DefinePlugin({
'process.env': JSON.stringify(process.env),
}),
];
if (process.env.BUNDLE_ANALYSER === 'true') {
plugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'server' }));
}
const config = {
mode: 'development',
devtool: 'source-map',
entry: resolve(__dirname, './src/index.tsx'),
devServer: {
historyApiFallback: true,
open: true,
hot: true,
liveReload: true,
port: portFinderSync.getPort(3301),
static: {
directory: resolve(__dirname, 'public'),
publicPath: '/',
watch: true,
},
allowedHosts: 'all',
},
target: 'web',
output: {
path: resolve(__dirname, './build'),
publicPath: '/',
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
plugins: [new TsconfigPathsPlugin({})],
},
module: {
rules: [
{
test: [/\.jsx?$/, /\.tsx?$/],
use: ['babel-loader'],
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
},
},
],
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
use: [
'file-loader?hash=sha512&digest=hex&name=img/[chunkhash].[ext]',
'image-webpack-loader?bypassOnDebug&optipng.optimizationLevel=7&gifsicle.interlaced=false',
],
},
{
test: /\.(ttf|eot|woff|woff2)$/,
use: ['file-loader'],
},
{
test: /\.less$/i,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
modules: true,
},
},
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
},
],
},
plugins,
performance: {
hints: false,
},
};
module.exports = config;