-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
75 lines (74 loc) · 2.13 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
// Modules
const path = require('path');
const dotenv = require('dotenv');
const HtmlWebpackPlugin = require('html-webpack-plugin'); // generate an HTML file and inject the necessary script tags automatically
dotenv.config();
module.exports = {
entry: path.join(__dirname, './frontend/src/', 'index.js'),
output: {
filename: 'bundle.js', // NOTE Specified name 'bundle.js' for when webpack builds app and generates a bundle containing all modules and dependencies
path: path.resolve(__dirname, 'build'),
},
mode: process.env.MODE,
module: {
rules: [
{
test: /\.(?:js|mjs|cjs|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', { targets: 'defaults' }], '@babel/preset-react'],
},
},
},
{
test: /\.(css|scss)$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.(png|jpg|jpeg|gif)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
outputPath: 'images/',
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
title: 'FlowMetrics',
template: path.join(__dirname, './frontend/public', 'index.html'),
}),
],
devServer: {
static: {
directory: path.join(__dirname, '/build'),
publicPath: '/',
},
hot: true, // enables Hot Module Replacement
historyApiFallback: true,
compress: true,
port: process.env.DEV_PORT,
proxy: [
{
'/api': {
target: `http://localhost:${process.env.SERV_PORT}/`,
},
},
],
},
resolve: {
extensions: ['.js', '.jsx'],
},
performance: {
hints: false, // webpack won't emit warnings based on these size limits during the build
maxEntrypointSize: 512000, // sets the max size, in bytes, that the entry point (main bundle) file should be before triggering a warning or error
maxAssetSize: 512000, // sets the maximum size for individual assets (like images, stylesheets, etc.)
},
};