-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
93 lines (84 loc) · 2.28 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
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const express = require("express");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const mockSurvey = require("./__files__/survey.json");
const mockFilterDefinition = require("./__files__/filter-definition.json");
module.exports = {
entry: path.join(__dirname, "src", "main"),
mode: "development",
devtool: "eval-source-map",
devServer: {
contentBase: path.join(__dirname, "dist"),
setup(app) {
app.use("/assets", express.static("__files__"));
app.get("/api/survey", (_, res) => res.json(mockSurvey));
app.get("/api/filter-definition", (_, res) =>
res.json(mockFilterDefinition)
);
},
},
// Default output configuration
output: {
path: path.join(__dirname, "dist"),
publicPath: "/",
filename: "[name].js",
chunkFilename: "[name].js",
globalObject: "this",
},
// Webpack performance options
performance: {
hints: false,
maxEntrypointSize: 320000,
},
// Resolving strategies for files
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
modules: [
path.join(__dirname, "src"),
path.join(__dirname, "node_modules"),
],
alias: {
"@": path.resolve(__dirname, "src"),
},
},
// Defualt loaders for most targets
module: {
rules: [
{
test: /\.(t|j)sx?$/,
exclude: [path.join(__dirname, "node_modules")],
use: [
{
loader: "babel-loader",
options: {
envName: "client",
},
},
],
},
{
test: /\.(css|postcss)$/,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.(sass|scss)$/,
use: ["style-loader", "css-loader", "postcss-loader", "sass-loader"],
},
{
test: /\.(less)$/,
use: ["style-loader", "css-loader", "postcss-loader", "less-loader"],
},
{
test: /\.(styl|stylus)$/,
use: ["style-loader", "css-loader", "postcss-loader", "stylus-loader"],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "src", "template.html"),
}),
new FaviconsWebpackPlugin("__files__/logo-favicon.svg"),
],
};