-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
81 lines (79 loc) · 1.93 KB
/
webpack.config.cjs
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
/* eslint-disable @typescript-eslint/no-require-imports */
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const Dotenv = require("dotenv-webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
// Basic configuration
entry: "./src/index.tsx",
// Necessary in order to use source maps and debug directly TypeScript files
devtool: "source-map",
mode: "development",
performance: {
maxAssetSize: 4000000,
maxEntrypointSize: 4000000,
},
module: {
rules: [
// Necessary in order to use TypeScript
{
test: /\.ts$|tsx/,
use: "ts-loader",
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
],
},
],
},
resolve: {
extensionAlias: {
".js": [".ts", ".tsx", ".js", ".cjs", ".mjs"],
},
extensions: [".ts", ".tsx", ".js", ".cjs", ".mjs"],
alias: {
"@lab": path.resolve(__dirname, "src/mod3"), // Change this line to change import paths!
}
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
// This line is VERY important for VS Code debugging to attach properly
// Tamper with it at your own risks
devtoolModuleFilenameTemplate: "[absolute-resource-path]",
clean: false,
},
plugins: [
// No need to write a index.html
new HtmlWebpackPlugin({
title: "HR Recruiting Manager",
favicon: "favicon.ico",
}),
// Load environment variables during webpack bundle
new Dotenv({
systemvars: true,
}),
// Extract CSS to separate file
new MiniCssExtractPlugin({
filename: "css/mystyles.css",
}),
],
devServer: {
port: 8080,
// Hot-reloading, the sole reason to use webpack here <3
hot: true,
},
};