-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
158 lines (154 loc) · 3.48 KB
/
webpack.config.js
File metadata and controls
158 lines (154 loc) · 3.48 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
146
147
148
149
150
151
152
153
154
155
156
157
158
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const LicensePlugin = require('webpack-license-plugin');
const VersionUpdatePlugin = require("./versionstampplugin.js");
const SitemapPlugin = require('sitemap-webpack-plugin').default;
const webpack = require('webpack');
var siteDescription = [
"Random Rants + is a high-performance realtime communication platform. ",
"Built by students focusing on WebRTC and secure P2P networking, ",
"featuring synchronized audio and interactive collaboration tools."
].join("");
var siteImage = "https://randomrants-plus.onrender.com/images/site-image.png";
const pages = [
"index",
"signin",
"signup",
"myaccount",
"chat",
"join",
"about",
"security",
"sitenews",
"history",
"legal",
"credits",
"updates",
"alts"
];
const paths = pages.map((page) => {
return {
path: '/'+page,
};
});
try {
require("fs").rmSync("./public", { recursive: true });
} catch (e) {}
module.exports = {
mode: "production",
cache: {
type: "filesystem",
allowCollectingMemory: true,
},
devtool: false,
entry: {
sw: "./src/serviceworker/index.js",
...pages.reduce((acc, page) => {
acc[page] = `./src/pages/${page}.js`;
return acc;
}, {})
},
optimization: {
splitChunks: {
chunks: "all",
name: "shared",
},
//minimize: false
},
output: {
path: path.resolve(__dirname, "public"),
filename: "[name].bundle.js",
},
watchOptions: {
ignored: [path.resolve(__dirname, "wpstatic/version.json")], //Ignore version file.
},
performance: {
hints: "warning",
assetFilter: function (assetFilename) {
//Ignore warnings for media assets which are typically large files.
return assetFilename.endsWith(".js") || assetFilename.endsWith(".css");
},
},
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "raw-loader",
options: {
esModule: false,
},
},
],
type: "javascript/auto", // Fix for raw-loader
},
{
test: /\.txt$/i,
use: [
{
loader: "raw-loader",
options: {
esModule: false,
},
},
],
type: "javascript/auto",
},
{
test: /\.ttf$/i,
use: [
{
loader: "url-loader",
},
],
},
{
test: /\.otf$/i,
use: [
{
loader: "url-loader",
},
],
},
],
},
plugins: [
...pages.map(
(page) =>
new HtmlWebpackPlugin({
filename: `${page}.html`,
title: `Random Rants +`,
description: siteDescription,
image: siteImage,
template: "./webpackhtml/base.html",
chunks: [page],
})
),
new CopyWebpackPlugin({
patterns: [
{
from: "./wpstatic",
to: ".",
noErrorOnMissing: true,
},
],
}),
new VersionUpdatePlugin(),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new LicensePlugin({ outputFilename: 'licenses.json' }),
new SitemapPlugin({
base: 'https://randomrants-plus.onrender.com',
paths,
options: {
filename: 'sitemap.xml',
lastmod: false,
changefreq: 'monthly',
priority: 0.9
}
})
],
};