Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
127 lines (115 loc) · 3.52 KB
/
Copy pathwebpack.config.js
File metadata and controls
127 lines (115 loc) · 3.52 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
const webpack = require("webpack");
const path = require("node:path");
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const createServiceInfo = require("./create_service_info");
const PDF_CMAPS_DIR = path.join(path.dirname(require.resolve("pdfjs-dist/package.json")), "cmaps");
const PDF_STANDARD_FONTS_DIR = path.join(
path.dirname(require.resolve("pdfjs-dist/package.json")), "standard_fonts");
module.exports = {
devtool: "source-map",
entry: ["babel-polyfill", path.resolve(__dirname, "./src/index.tsx")],
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: ["ts-loader"],
},
{
test: /.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
type: 'asset/resource',
},
],
},
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
extensions: ["*", ".tsx", ".ts", ".js", ".jsx"],
},
output: {
path: path.resolve(__dirname, "dist"),
publicPath: "/",
filename: "[name].js",
chunkFilename: "[name].[contenthash].bundle.js",
sourceMapFilename: "[file].map",
clean: true,
},
optimization: {
splitChunks: {
chunks: "all"
},
},
plugins: [
new CopyPlugin({
patterns: [
{from: "static", to: "static"},
{from: PDF_CMAPS_DIR, to: "cmaps/"},
{from: PDF_STANDARD_FONTS_DIR, to: "standard_fonts/"},
],
}),
new HtmlWebpackPlugin({
title: "Bento",
template: path.resolve(__dirname, "./src/template.html"),
hash: true,
}),
new webpack.EnvironmentPlugin({
// Default environment variables to null if not set
BENTO_URL: null,
BENTO_PUBLIC_URL: null,
BENTO_CBIOPORTAL_ENABLED: false,
BENTO_MONITORING_ENABLED: false,
BENTO_CBIOPORTAL_PUBLIC_URL: null,
CUSTOM_HEADER: null,
CLIENT_ID: null,
OPENID_CONFIG_URL: null,
NODE_ENV: "production",
}),
],
watchOptions: {
aggregateTimeout: 200,
poll: 1000,
ignored: /node_modules/,
},
devServer: {
static: {
directory: path.join(__dirname, "static"),
},
compress: true,
historyApiFallback: {
// Allows url parameters containing dots in the devServer
disableDotRule: true
},
host: "0.0.0.0",
port: process.env.BENTO_WEB_PORT ?? 9000,
watchFiles: {
paths: [
"src/**/*.js",
"src/**/*.html",
"static/**/*",
],
options: {
usePolling: true,
},
},
devMiddleware: {
writeToDisk: true,
},
setupMiddlewares(middlewares, devServer) {
if (!devServer) {
throw new Error("webpack-dev-server is not defined");
}
devServer.app.get("/service-info", (req, res) => {
res.header("Content-Type", "application/json");
res.json(createServiceInfo.serviceInfo);
});
return middlewares;
},
allowedHosts: "all",
},
};