-
Notifications
You must be signed in to change notification settings - Fork 2
/
nuxt.config.js
234 lines (218 loc) · 6.64 KB
/
nuxt.config.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/* eslint-env node */
import axios from 'axios'
import _get from "lodash/get"
export default {
server: {
port: 3000,
host: "0.0.0.0",
},
target: "static",
components: true,
privateRuntimeConfig: {
esWriteKey: process.env.ES_WRITE_KEY,
},
publicRuntimeConfig: {
host: process.env.SITEMAP_HOST,
s3Bucket: process.env.S3_BUCKET,
esReadKey: process.env.ES_READ_KEY || "",
esIndex: process.env.ES_INDEX || "",
libguidesEsIndex: process.env.LIBGUIDES_ES_INDEX || "",
esIndexPrefix: process.env.ES_INDEX_PREFIX || "",
esTempIndexPrefixLibguides: process.env.ES_TEMP_INDEX_PREFIX_LIBGUIDES || "",
esTempIndex: "",
esTempIndexLibguides: "",
esURL: process.env.ES_URL || "",
libcalProxy:
process.env.LIBCAL_ENDPOINT ||
"https://proxy.calendar.library.ucla.edu/",
},
/*
** Required charset and viewport meta tags
*/
head: {
htmlAttrs: {
lang: "en",
},
meta: [
{ charset: "utf-8" },
{
name: "viewport",
content:
"width=device-width, initial-scale=1.0, minimum-scale=1.0",
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Global CSS
*/
css: [
"ucla-library-design-tokens/scss/fonts.scss",
"ucla-library-design-tokens/scss/app-global.scss",
"~/assets/styles/global.scss",
],
/*
** Load SCSS into each component
*/
styleResources: {
scss: ["ucla-library-design-tokens/scss/app.scss"],
},
/*
** Plugins to load before mounting the App
*/
plugins: [
"~/plugins/add-library-website-vue-components.js",
"~/plugins/preview.client.js",
"~/plugins/browser-events.client.js",
"~/plugins/craft.js",
"~/plugins/data-api.js",
"~/plugins/elasticsearchplugin.js",
"~/plugins/get-headers.client.js",
"~/plugins/scrape-formid.client.js",
"~/plugins/add-skip-to.js",
"~/plugins/update-library-site-alert.client.js",
],
/*
* Axios. Used for Libcal query.
*/
axios: {
baseURL:
process.env.LIBCAL_ENDPOINT ||
"https://proxy.calendar.library.ucla.edu/",
},
/*
* GraphQL Request. Used for querying from Craft
*/
graphql: {
clients: {
default: {
endpoint: process.env.CRAFT_ENDPOINT,
options: {},
},
},
},
/*
** Nuxt generate configuration. Used when generating a static site.
*/
generate: {
// exclude is for npm run genereate uncomment for local builds
// exclude:[/^\/help/,/^\/visit/,/^\/give/,/^\/help/,/^\/give/,/^\/impact/],
fallback: "404.html",
interval: 500,
concurrency: 10,
async routes() {
const result = await axios({
url: process.env.CRAFT_ENDPOINT,
method: "post",
data: { query: 'query EventsExhibitionsList { events: entries(section: "event") { uri } series: entries(section: "workshopOrEventSeries") { uri } exhibitions: entries(section: "exhibition") { uri } }' },
})
return [
..._get(result, "data.data.events", []),
..._get(result, "data.data.series", []),
..._get(result, "data.data.exhibitions", []),
].map(entry => "/" + entry.uri)
},
},
/*
** Page transition
*/
pageTransition: {
name: "fade",
mode: "out-in",
},
/*
** Customize the progress-bar color
** See: https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-loading
*/
loading: {
color: "#ffe800",
height: "3px",
},
/*
** Nuxt router configuration. Used to define settingg for the router.
*/
// TODO find out later why this causing the live preview to not work
/*router: {
trailingSlash: false,
},*/
/*
* Nuxt modules
*/
modules: [
"~/modules/populate",
"@nuxtjs/axios",
"@nuxtjs/gtm",
"nuxt-robots-module",
"@nuxtjs/sitemap",
], // This needs to be last always,
gtm: {
id: "GTM-T2SXV2",
},
sitemap: {
hostname:
process.env.SITEMAP_HOST || "https://www.library.ucla.edu",
routes: [],
},
/*
* Nuxt build modules
*/
buildModules: [
"@nuxtjs/router-extras",
"@nuxtjs/style-resources",
"nuxt-graphql-request",
"@/modules/sitemapRouteGenerator",
"@/modules/indexAliasGenerator",
"@/modules/swapAliasIndexGenerator",
],
/*
** Nuxt webpack build configuration
*/
build: {
// eslint-disable-next-line no-unused-vars
extend(config, ctx) {
// Remove SVG from default Nuxt webpack rules, add back in rule without SVGs
const svgRule = config.module.rules.find((rule) =>
rule.test.test(".svg")
)
svgRule.test = /\.(png|jpe?g|gif|webp)$/i
// Add custom loading of SVGs as Vue components
config.resolve.extensions.push(".svg")
config.module.rules.push({
test: /\.svg$/,
oneOf: [
{
// ?raw on import will give raw SVG with no optimizations.
// Good if you need unaltered SVGs for animations.
resourceQuery: /raw/,
use: [
"babel-loader",
{
loader: "vue-svg-loader",
options: {
svgo: false,
},
},
],
},
{
// ?url on import will give base64 encoded SVG.
// Good for use in CSS.
resourceQuery: /url/,
use: ["url-loader"],
},
{
// Default SVG loader, custom SVGO options
loader: "vue-svg-loader",
options: {
svgo: {
plugins: [{ removeViewBox: false }],
},
},
},
],
})
},
},
}