This repository has been archived by the owner on May 5, 2023. It is now read-only.
forked from MeditationDuck/covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.ts
292 lines (285 loc) · 7.31 KB
/
nuxt.config.ts
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
import { NuxtConfig } from '@nuxt/types'
import dayjs, { extend } from 'dayjs'
import utc from 'dayjs/plugin/utc'
// eslint-disable-next-line no-restricted-imports
import i18nOptions from './i18n.config'
const environment = process.env.NODE_ENV || 'development'
extend(utc)
const now = dayjs().utc().format()
const pages = [
'/cards/confirmed-cases-area/',
'/cards/age-group/',
'/cards/stage/',
'/cards/health-burden',
'/cards/health-burden-hospital',
'/cards/weekly-map/',
'/cards/clinic-map/',
'/cards/whats-new/',
'/cards/self-disclosures/',
'/cards/details-of-confirmed-cases/',
'/cards/number-of-confirmed-cases/',
'/cards/monitoring-number-of-confirmed-cases/',
'/cards/monitoring-number-of-confirmed-cases-per-100k/',
'/cards/effective-reproduction-number/',
'/cards/untracked-rate/',
'/cards/positive-rate/',
'/cards/number-of-hospitalized/',
'/cards/attributes-of-confirmed-cases/',
'/cards/number-of-confirmed-cases-by-municipalities/',
'/cards/number-of-tested/',
'/cards/hospital-capacity/',
'/cards/hotel-capacity/',
'/cards/home-capacity/',
'/cards/restaurant-map/',
]
const config: NuxtConfig = {
target: 'static',
components: false, // disable components auto import
/*
** Headers of the page
*/
head: {
htmlAttrs: {
prefix: 'og: http://ogp.me/ns#',
},
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'og:type', property: 'og:type', content: 'website' },
{
hid: 'og:url',
property: 'og:url',
content: 'https://iwate.stopcovid19.jp',
},
{
hid: 'twitter:card',
name: 'twitter:card',
content: 'summary_large_image',
},
{
hid: 'fb:app_id',
property: 'fb:app_id',
content: '320122459207066',
},
{
hid: 'note:card',
property: 'note:card',
content: 'summary_large_image',
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'apple-touch-icon', href: '/apple-touch-icon-precomposed.png' },
],
script: [
{
src: 'https://polyfill.io/v3/polyfill.min.js?features=IntersectionObserver',
defer: true,
},
],
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: ['@/assets/global.scss'],
/*
** Plugins to load before mounting the App
*/
plugins: [
{
src: '@/plugins/vue-chart.ts',
ssr: true,
},
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
'@nuxtjs/pwa',
'@nuxtjs/stylelint-module',
'@nuxtjs/vuetify',
'@nuxt/typescript-build',
'@nuxtjs/gtm',
'nuxt-purgecss',
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://github.com/nuxt-community/dotenv-module
['@nuxtjs/dotenv', { filename: `.env.${environment}` }],
['@nuxtjs/i18n', i18nOptions],
'nuxt-svg-loader',
'@nuxtjs/sitemap',
],
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
*/
vuetify: {
customVariables: ['@/assets/variables.scss'],
optionsPath: './plugins/vuetify.options.ts',
treeShake: true,
defaultAssets: false,
},
gtm: {
id: 'GTM-WQK97B9',
pageTracking: true,
enabled: true,
},
/*
* nuxt-i18n による自動リダイレクトを停止したためコメントアウト
* @todo 「Cookieがあるときのみ、その言語にリダイレクトする」を実装する場合は復活させる
* 実装しない場合は以下の記述を完全に削除する
*/
/* optionalCookies: [
{
name: 'i18n_redirected',
label: 'i18n Redirection Cookie',
description:
'For automatically switching UI languages in accordance with locale preferences in the web browser configuration.',
cookies: ['i18n_redirected']
}
], */
build: {
babel: {
presets() {
return [
[
'@nuxt/babel-preset-app',
{
corejs: { version: '3' },
},
],
]
},
},
postcss: {
preset: {
autoprefixer: {
// Built-in since [email protected]
grid: 'autoplace',
},
},
},
extend(config) {
// default externals option is undefined
config.externals = [{ moment: 'moment' }]
},
},
purgeCSS: {
enabled: true,
paths: [
'./node_modules/vuetify/dist/vuetify.js',
'./node_modules/vue-spinner/src/ScaleLoader.vue',
],
whitelist: ['DataCard', 'GraphLegend'],
whitelistPatterns: [/(col|row)/],
// This is nuxt-purgecss 1.0.0 default settings
// https://github.com/Developmint/nuxt-purgecss#defaults
// This extractor purge <style module>
// <style scoped> is not purged by default whitelistPatterns
//
// extractors: [
// {
// extractor: (content: string) => {
// const contentWithoutStyleBlocks = content.replace(
// /<style[^]+?<\/style>/gi,
// ''
// ) // Remove inline vue styles
// return contentWithoutStyleBlocks.match(/[\w-.:/]+(?<!:)/g) || []
// },
// extensions: ['html', 'vue', 'js'],
// },
// ],
//
// so override extractors
// https://github.com/Developmint/nuxt-purgecss#use-custom-extractors
extractors: () => [
{
extractor(content: string): RegExpMatchArray | null {
return content.match(/[A-z0-9-:\\/]+/g)
},
extensions: ['html', 'vue', 'js'],
},
],
},
pwa: {
meta: {
theme_color: '#00a040',
lang: 'ja',
},
manifest: {
name: '岩手県 新型コロナウイルス感染症対策サイト 非公式',
short_name: '岩手COVID19',
lang: 'ja',
},
workbox: {
enabled: false,
},
},
router: {
trailingSlash: true,
extendRoutes(routes) {
routes.forEach((route) => {
if (route.name === 'index' || route.name === 'reference') {
route.meta = { tabs: true }
}
})
},
},
generate: {
fallback: true,
routes() {
const locales = ['en']
const localizedPages = locales
.map((locale) => pages.map((page) => `/${locale}${page}`))
.reduce((a, b) => [...a, ...b], [])
return [...pages, ...localizedPages]
},
},
// /*
// ** hot read configuration for docker
// */
watchers: {
webpack: {
poll: true,
},
},
sitemap: {
hostname: 'https://iwate.stopcovid19.jp/',
gzip: true,
trailingSlash: true,
exclude: [
// @nuxtjs/sitemapがpagesしかi18n対応していないので、自動生成される分をexcludeで全て外しておいて、
// routes()で手動で管理することで多言語対応のhreflang付きのsitemapを生成するworkaround
'/',
'/en/',
'**/about',
'**/flow',
'**/vaccine/',
'**/worker',
'**/print/flow',
],
defaults: {
changefreq: 'daily',
priority: 1,
lastmod: now,
},
routes() {
return ['/', '/about/', '/flow/', '/vaccine/', '/worker/', ...pages].map(
(page) => ({
url: `${page}`,
links: [
{ lang: 'ja', url: `${page}` },
{ lang: 'en', url: `/en${page}` },
],
})
)
},
},
}
export default config