-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.prod.js
191 lines (182 loc) · 5.15 KB
/
webpack.prod.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const postcssGlobalData = require("@csstools/postcss-global-data");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const webpack = require("webpack");
const postcssPresetEnv = require("postcss-preset-env");
const API_URL = process.env.API_URL || "https://api.unison-lang.org";
const UI_CORE_SRC = "elm-stuff/gitdeps/github.com/unisonweb/ui-core/src";
const WEBSITE_URL = process.env.WEBSITE_URL || "https://www.unison-lang.org";
const unisonShareCfg = {
module: {
rules: [
{
test: /\.css$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: { importLoaders: 1 },
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
postcssGlobalData({
files: [`${UI_CORE_SRC}/css/ui/viewport.css`],
}),
postcssPresetEnv({
features: {
"is-pseudo-class": false,
"nesting-rules": true,
"has-pseudo-class": true,
},
}),
],
},
},
},
],
},
{
test: /\.md$/i,
type: "asset/source",
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
},
{
test: /\.(woff(2)?|ttf|eot)$/i,
type: "asset/resource",
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
use: [
{
loader: "elm-asset-webpack-loader",
},
{
loader: "elm-webpack-loader",
options: {
debug: false,
optimize: true,
cwd: __dirname,
},
},
],
},
],
},
resolve: {
alias: {
assets: path.resolve(__dirname, "src/assets/"),
"ui-core": path.resolve(__dirname, UI_CORE_SRC + "/"),
},
},
entry: "./src/unisonShare.js",
plugins: [
new HtmlWebpackPlugin({
template: "./src/unisonShare.ejs",
inject: "body",
publicPath: "/static/",
base: "/",
filename: path.resolve(__dirname, "dist/unisonShare/index.html"),
}),
new FaviconsWebpackPlugin({
logo: "./src/assets/favicon.svg",
inject: true,
favicons: {
appName: "Unison Share",
appDescription: "Explore, read docs about, and share Unison libraries",
developerName: "Unison",
developerURL: "https://unison-lang.org",
background: "#C6A8EC",
theme_color: "#C6A8EC",
},
}),
new CopyPlugin({
patterns: [
{
from: "src/assets/unison-share-social.png",
to: "unison-share-social.png",
},
{
from: "src/assets/unison-logo-circle.png",
to: "unison-logo-circle.png",
},
{
from: "src/assets/unison-logo-square.png",
to: "unison-logo-square.png",
},
{
from: "src/assets/unison-cloud-splash.svg",
to: "unison-cloud-splash.svg",
},
// These are for social images in netlify/edge-functions
{
from: "src/assets/edge-functions/social-image-background.png",
to: "social-image-background.png",
},
{
from: "src/assets/edge-functions/no-avatar.png",
to: "no-avatar.png",
},
{
from: "src/assets/edge-functions/Inter-Regular.ttf",
to: "Inter-Regular.ttf",
},
{
from: "src/assets/edge-functions/Inter-Bold.ttf",
to: "Inter-Bold.ttf",
},
{
from: "src/assets/edge-functions/Inter-Black.ttf",
to: "Inter-Black.ttf",
},
{
from: "src/assets/edge-functions/FiraCode-Regular.ttf",
to: "FiraCode-Regular.ttf",
},
{
from: "src/assets/edge-functions/FiraCode-Bold.ttf",
to: "FiraCode-Bold.ttf",
},
{
from: "src/robots.txt",
to: path.resolve(__dirname, "dist/unisonShare/robots.txt"),
},
{
from: "src/sitemap.txt",
to: path.resolve(__dirname, "dist/unisonShare/sitemap.txt"),
},
{
from: "src/404.html",
to: path.resolve(__dirname, "dist/unisonShare/404.html"),
},
{
from: "src/500.html",
to: path.resolve(__dirname, "dist/unisonShare/500.html"),
},
{
from: "src/maintenance.html",
to: path.resolve(__dirname, "dist/unisonShare/maintenance.html"),
},
],
}),
new webpack.DefinePlugin({
API_URL: JSON.stringify(API_URL),
WEBSITE_URL: JSON.stringify(WEBSITE_URL),
APP_ENV: JSON.stringify("production"),
}),
],
output: {
filename: "[name].[contenthash].js",
path: path.resolve(__dirname, "dist/unisonShare/static"),
clean: true,
},
};
module.exports = unisonShareCfg;