Skip to content

Commit ef7ab9b

Browse files
committed
Revert file unrelevant to this work
1 parent 865707c commit ef7ab9b

1 file changed

Lines changed: 154 additions & 0 deletions

File tree

webpack.config.js

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
const webpack = require("webpack");
2+
const pkg = require("./package.json");
3+
const CopyPlugin = require("copy-webpack-plugin");
4+
const path = require("path");
5+
6+
function resolvePath(p) {
7+
return path.resolve(__dirname, p);
8+
}
9+
10+
const config = [
11+
{
12+
entry: {
13+
UV: ["./src/index.ts"],
14+
},
15+
mode: "production",
16+
output: {
17+
path: resolvePath("dist/umd"),
18+
publicPath: "auto",
19+
libraryTarget: "umd",
20+
library: "UV",
21+
umdNamedDefine: true,
22+
chunkFilename: "[name].[contenthash].js",
23+
},
24+
resolve: {
25+
extensions: [".ts", ".tsx", ".js"],
26+
fallback: {
27+
zlib: false,
28+
stream: false,
29+
},
30+
},
31+
module: {
32+
rules: [
33+
{
34+
test: /\.ts$/,
35+
use: [{ loader: "ts-loader" }],
36+
},
37+
{
38+
test: /\.tsx$/,
39+
use: [{ loader: "ts-loader" }],
40+
},
41+
{
42+
test: /\.css$/i,
43+
use: ["style-loader", "css-loader"],
44+
},
45+
{
46+
test: /\.less$/,
47+
use: [
48+
{
49+
loader: "style-loader",
50+
},
51+
{
52+
loader: "css-loader",
53+
options: {
54+
sourceMap: true,
55+
},
56+
},
57+
{
58+
loader: "less-loader",
59+
options: {
60+
lessOptions: {
61+
strictMath: true,
62+
},
63+
},
64+
},
65+
],
66+
},
67+
{
68+
test: /\.(png|jpg|gif|svg)$/i,
69+
use: [
70+
{
71+
loader: "url-loader",
72+
options: {
73+
limit: 8192,
74+
},
75+
},
76+
],
77+
},
78+
],
79+
},
80+
plugins: [
81+
new webpack.EnvironmentPlugin({
82+
PACKAGE_VERSION: pkg.version,
83+
}),
84+
new webpack.ProvidePlugin({
85+
$: "jquery",
86+
jQuery: "jquery",
87+
"window.jQuery": "jquery",
88+
}),
89+
new CopyPlugin({
90+
patterns: [
91+
{
92+
from: resolvePath("./src/index.html"),
93+
to: resolvePath("./dist"),
94+
transform(content) {
95+
return Promise.resolve(
96+
Buffer.from(
97+
content
98+
.toString()
99+
.replace(
100+
"<%= htmlWebpackPlugin.tags.headTags %>",
101+
'<script type="text/javascript" src="umd/UV.js"></script>'
102+
),
103+
"utf8"
104+
)
105+
);
106+
},
107+
},
108+
{
109+
from: resolvePath("./src/iiif-collection.json"),
110+
to: resolvePath("./dist"),
111+
},
112+
{
113+
from: resolvePath("./src/youtube-collection.json"),
114+
to: resolvePath("./dist"),
115+
},
116+
{
117+
from: resolvePath("./src/favicon.ico"),
118+
to: resolvePath("./dist"),
119+
},
120+
{
121+
from: resolvePath("./src/uv-iiif-config.json"),
122+
to: resolvePath("./dist"),
123+
},
124+
{
125+
from: resolvePath("./src/uv-youtube-config.json"),
126+
to: resolvePath("./dist"),
127+
},
128+
{
129+
from: resolvePath("./src/uv.css"),
130+
to: resolvePath("./dist"),
131+
},
132+
{
133+
from: resolvePath("./src/uv.html"),
134+
to: resolvePath("./dist"),
135+
},
136+
{
137+
from: resolvePath("./node_modules/mediaelement/build/mejs-controls.svg"),
138+
to: resolvePath("./dist"),
139+
}
140+
],
141+
}),
142+
],
143+
},
144+
];
145+
146+
if (process.env.NODE_WEBPACK_LIBRARY_PATH) {
147+
config.output.path = resolvePath(process.env.NODE_WEBPACK_LIBRARY_PATH);
148+
}
149+
150+
if (process.env.NODE_WEBPACK_LIBRARY_TARGET) {
151+
config.output.libraryTarget = process.env.NODE_WEBPACK_LIBRARY_TARGET;
152+
}
153+
154+
module.exports = config;

0 commit comments

Comments
 (0)