forked from WordPress/openverse-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.js
218 lines (213 loc) · 5.39 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
import pkg from './package.json'
import locales from './src/locales/scripts/valid-locales.json'
/**
* Default environment variables are set on this key. Defaults are fallbacks to existing env vars.
*/
export const env = {
apiUrl: process.env.API_URL || 'https://api.creativecommons.engineering/v1/',
socialSharing: process.env.SOCIAL_SHARING || true,
enableGoogleAnalytics: process.env.ENABLE_GOOGLE_ANALYTICS || false,
googleAnalyticsUA: process.env.GOOGLE_ANALYTICS_UA || 'UA-2010376-36',
filterStorageKey: 'openverse-filter-visibility',
notificationStorageKey: 'openverse-show-notification',
enableInternalAnalytics: process.env.ENABLE_INTERNAL_ANALYTICS || false,
}
/**
* The default metadata for the site. Can be extended and/or overwritten per page. And even in components!
* See the Nuxt.js docs for more info.
* {@link https://nuxtjs.org/guides/features/meta-tags-seo Nuxt.js Docs}
*/
const meta = [
{ charset: 'utf-8' },
{
name: 'description',
content:
'A new Openverse search tool for creators seeking to discover and reuse free resources with greater ease.',
},
{ name: 'viewport', content: 'width=device-width,initial-scale=1' },
{ name: 'twitter:card', content: 'summary_large_image' },
{ name: 'twitter:site', content: '@creativecommons' },
{ name: 'og:title', content: 'Openverse' },
{
name: 'og:image',
content: '/cclogo-shared-image.jpg',
},
{
name: 'og:description',
content:
'Empowering the world to share through 6 simple licenses + a global community of advocates for open.',
},
{
name: 'og:url',
content: 'https://creativecommons.org',
},
{
name: 'og:site_name',
content: 'Creative Search',
},
{
vmid: 'monetization',
name: 'monetization',
content: '$ilp.uphold.com/edR8erBDbRyq',
},
]
if (process.env.NODE_ENV === 'production') {
meta.push({
'http-equiv': 'Content-Security-Policy',
content: 'upgrade-insecure-requests',
})
}
// Default html head
const head = {
title: 'Openverse',
meta,
link: [
{
rel: 'preconnect',
href: env.apiUrl,
crossorigin: '',
},
{
rel: 'dns-prefetch',
href: env.apiUrl,
},
{
rel: 'search',
type: 'application/opensearchdescription+xml',
title: 'Openverse',
href: '/opensearch.xml',
},
{
rel: 'icon',
type: 'image/png',
href: '/app-icons/cc-site-icon-150x150.png',
sizes: '32x32',
},
{
rel: 'icon',
type: 'image/png',
href: '/app-icons/cc-site-icon-300x300.png',
sizes: '192x192',
},
{
rel: 'apple-touch-icon-precomposed',
type: 'image/png',
href: '/app-icons/cc-site-icon-300x300.png',
sizes: '192x192',
},
],
}
export default {
// eslint-disable-next-line no-undef
version: pkg.version, // used to purge cache :)
cache: {
pages: ['/'],
store: {
type: 'memory', // 'redis' would be nice
max: 100,
ttl: process.env.MICROCACHE_DURATION || 60,
},
},
srcDir: 'src/',
modern: 'client',
server: { port: process.env.PORT || 8443 },
router: {
middleware: 'middleware',
},
components: {
dirs: [
'~/components',
'~/components/ContentReport',
'~/components/Filters',
'~/components/ImageDetails',
'~/components/MediaInfo',
'~/components/MetaSearch',
],
},
plugins: [
{ src: '~/plugins/ab-test-init.js', mode: 'client' },
{ src: '~/plugins/ga.js', mode: 'client' },
{ src: '~/plugins/url-change.js' },
{ src: '~/plugins/migration-notice.js' },
],
css: [
'~/assets/fonts.css',
'~/styles/vocabulary.scss',
'~/styles/global.scss',
],
head,
env,
dev: process.env.NODE_ENV !== 'production',
buildModules: [
'@nuxtjs/composition-api/module',
'@nuxtjs/tailwindcss',
'@nuxtjs/style-resources',
'@nuxtjs/svg',
'@nuxtjs/eslint-module',
],
// Load the scss variables into every component:
// No need to import them. Since the variables will not exist in the final build,
// this doesn't make the built files larger.
styleResources: {
scss: ['./styles/utilities/all.scss'],
},
modules: [
'@nuxtjs/sentry',
'@nuxtjs/sitemap',
'nuxt-ssr-cache',
'@nuxtjs/i18n',
],
i18n: {
locales: [
{
code: 'en',
name: 'English',
iso: 'en',
file: 'en.json',
},
...(locales ?? []),
],
lazy: true,
langDir: 'locales',
strategy: 'no_prefix',
defaultLocale: 'en',
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
alwaysRedirect: true,
},
baseUrl: 'http://localhost:8443',
vueI18n: '~/plugins/vue-i18n.js',
},
sentry: {
dsn:
process.env.SENTRY_DSN ||
'https://[email protected]/1525413',
lazy: true,
},
tailwindcss: {
// https://github.com/nuxt-community/tailwindcss-module/issues/114#issuecomment-698885369
configPath: '~~/tailwind.config.js',
},
storybook: {
port: 6006, // standard port for Storybook
stories: ['~/**/*.stories.@(mdx|js)'],
addons: [
{
name: '@storybook/addon-essentials',
options: {
backgrounds: false,
viewport: false,
toolbars: false,
},
},
],
parameters: {
options: {
storySort: {
order: ['Introduction', ['Openverse UI']],
},
},
},
},
}