Repository navigation
Expand file tree
/
Copy pathwebpack.dev-server.js
More file actions
145 lines (143 loc) Β· 3.72 KB
/
Copy pathwebpack.dev-server.js
File metadata and controls
145 lines (143 loc) Β· 3.72 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const express = require("express");
const webpack = require("webpack");
const pkg = require("./package.json");
const config = {
entry: {
UV: ["./src/index.ts"],
},
mode: "development",
devtool: "eval-source-map",
output: {
libraryTarget: "umd",
library: "UV",
umdNamedDefine: true,
chunkFilename: "[name].[contenthash].js",
globalObject: "this",
},
resolve: {
alias: {
jquery: require.resolve("jquery/dist/jquery.js"),
},
extensions: [".ts", ".tsx", ".js"],
fallback: {
zlib: false,
stream: false,
},
},
module: {
rules: [
{ test: /\.js$/, loader: "source-map-loader", enforce: "pre" },
{
test: /\.ts$/,
use: [{ loader: "ts-loader" }],
},
{
test: /\.tsx$/,
use: [{ loader: "ts-loader" }],
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.less$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
options: {
sourceMap: true,
},
},
{
loader: "less-loader",
options: {
lessOptions: {
strictMath: true,
},
additionalData: '@theme: "uv-en-gb-theme";',
},
},
],
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
],
},
devServer: {
static: {
directory: path.join(__dirname),
// chokidar 5 (webpack-dev-server 6) has no macOS fsevents support, so
// watching node_modules too runs out of file handles (EMFILE).
watch: { ignored: /[\\/]node_modules[\\/]/ },
},
open: true,
compress: true,
port: 8080,
onListening(devServer) {
devServer.app.use("/docs", express.static(path.join(__dirname, "docs")));
devServer.app.use(
"/iiif-collection.json",
express.static(path.join(__dirname, "src", "iiif-collection.json"))
);
devServer.app.use(
"/youtube-collection.json",
express.static(path.join(__dirname, "src", "youtube-collection.json"))
);
devServer.app.use(
"/uv-iiif-config.json",
express.static(path.join(__dirname, "src", "uv-iiif-config.json"))
);
devServer.app.use(
"/uv-youtube-config.json",
express.static(path.join(__dirname, "src", "uv-youtube-config.json"))
);
devServer.app.use(
"/uv.css",
express.static(path.join(__dirname, "src", "uv.css"))
);
devServer.app.use(
"/mejs-controls.svg",
express.static(path.join(__dirname, "node_modules" , "mediaelement", "build", "mejs-controls.svg"))
);
},
},
plugins: [
new webpack.EnvironmentPlugin({
PACKAGE_VERSION: `${pkg.version} (development)`,
}),
new HtmlWebpackPlugin({
title: "UV Examples",
template: "./src/index.html",
minify: false,
inject: "head",
}),
new HtmlWebpackPlugin({
title: "UV Examples",
template: "./src/uv.html",
filename: "uv.html",
minify: false,
inject: "head",
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
}),
],
ignoreWarnings: [/Failed to parse source map/],
};
module.exports = config;