-
Notifications
You must be signed in to change notification settings - Fork 2
/
nuxt.config.ts
295 lines (287 loc) · 7.5 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
293
294
295
import fs from 'fs'
import path from 'path'
import { NuxtConfig } from '@nuxt/types'
import pkg from './package.json'
import {
BASE_PATH,
createNuxtFeedCreate,
fromPackageToAppIdentity,
IS_CI,
nuxtContentHooks,
getNuxtContentAllPages,
getNuxtContentAllLinks,
} from './lib'
import tailwindConfig from './tailwind.config'
const appIdentity = {
// #TODO Configure this somewhere else. Also, this is more of a "configuration" than an "identity"
...fromPackageToAppIdentity(pkg, 'America/Montreal'),
description: 'Fascinated By The Open Web Platform',
}
const isProduction = process.env.NODE_ENV === 'production'
// #TODO
// - [ ] site-map.xml
// - [x] RSS Feed
// - [ ] list of all URLs to articles markdown files published with title, created, locale
// - [ ] During build, remove search index we do not use https://damieng.com/blog/2024/05/14/nuxt-content-db-and-size/
const main: NuxtConfig = {
/*
** Nuxt target
** See https://nuxtjs.org/api/configuration-target
*/
target: 'static',
vue: {
config: {
ignoredElements: [/^rb-/],
},
},
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
titleTemplate: '%s - ' + appIdentity.name,
title: appIdentity.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || '',
},
{
property: 'og:image',
content:
'https://secure.gravatar.com/avatar/cbf8c9036c204fe85e15155f9d70faec?s=400',
},
{
property: 'twitter:card',
content: 'summary_large_image',
},
{
property: 'twitter:site',
content: '@renoirb',
},
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'alternate',
type: 'application/rss+xml',
title: 'Renoir Boulanger’s Page Updates RSS Feed',
href: 'https://renoirboulanger.com/feed.xml',
},
{
rel: 'alternate',
type: 'application/feed+json',
title: 'Renoir Boulanger’s Page Updates Feed',
href: 'https://renoirboulanger.com/feed.json',
},
],
script: [
// <script src="https://myawesome-lib.js"></script>
// { src: 'https://awesome-lib.js' },
// https://vue-meta.nuxtjs.org/api/#script
{
src: './main.mjs',
type: 'module',
defer: true,
},
],
__dangerouslyDisableSanitizers: [
/* YOLO. Plus, I don’t want WebPack to inline and mangle what’s here. */ 'script',
],
},
env: {
...appIdentity,
},
hooks: {
...nuxtContentHooks,
// reminder: don't have two hooks the same
'generate:distCopied': (generator) => {
const content = getNuxtContentAllPages()
let fullyQualifiedFilePath = path.join(
generator.options.generate.dir,
'content.json',
)
fs.writeFileSync(fullyQualifiedFilePath, JSON.stringify(content))
const allLinks = getNuxtContentAllLinks()
fullyQualifiedFilePath = path.join(
generator.options.generate.dir,
'links.csv',
)
fs.writeFileSync(
fullyQualifiedFilePath,
Array.from(new Set(allLinks)).join('\n'),
)
},
},
/*
** Global CSS
*/
css: ['~assets/styles/main.css'],
loading: { color: '#CB7723' /* charlie */ },
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: ['~/plugins/prism'],
/*
** Auto import components
** See https://nuxtjs.org/api/configuration-components
*/
components: true,
router: {
middleware: ['init', 'redirects'],
base: BASE_PATH,
extendRoutes(routes, resolve) {
routes.push({
name: 'custom',
path: '*',
component: resolve(__dirname, 'pages/error-404.vue'),
})
},
},
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/color-mode-module
'@nuxtjs/color-mode',
'@nuxtjs/tailwindcss',
'@nuxt/typescript-build',
// Doc: https://github.com/nuxt-community/stylelint-module
'@nuxtjs/stylelint-module',
'@nuxtjs/composition-api',
'nuxt-purgecss',
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://github.com/nuxt/content
'@nuxt/content',
'@nuxtjs/feed',
'nuxt-purgecss',
'nuxt-webfontloader',
],
/*
** Content module configuration
** See:
** - https://content.nuxtjs.org/configuration
** - https://content.nuxtjs.org/configuration#defaults
*/
content: {
markdown: {
prism: {
theme: 'prism-themes/themes/prism-material-oceanic.css',
},
},
},
feed: [
{
path: '/feed.xml',
async create(feed, args) {
const { $content } = require('@nuxt/content')
const nuxtFeedCreate = createNuxtFeedCreate($content)
await nuxtFeedCreate(feed, args)
},
cacheTime: 1000 * 60 * 15,
type: 'rss2',
data: {
BASE_PATH,
appIdentity: {
...appIdentity,
homepage:
'https://renoirboulanger.com' /** #TODO Fix build for this */,
},
isProduction,
},
},
{
path: '/feed.json',
async create(feed, args) {
const { $content } = require('@nuxt/content')
const nuxtFeedCreate = createNuxtFeedCreate($content)
await nuxtFeedCreate(feed, args)
},
cacheTime: 1000 * 60 * 15,
type: 'json1',
data: {
BASE_PATH,
appIdentity: {
...appIdentity,
homepage:
'https://renoirboulanger.com' /** #TODO Fix build for this */,
},
isProduction,
},
},
],
// https://tailwindcss.nuxtjs.org/setup/
tailwindcss: {
cssPath: '~/assets/styles/main.css',
configPath: '~/tailwind.config.js',
// add '~tailwind.config` alias
exposeConfig: true,
config: tailwindConfig,
},
// https://color-mode.nuxtjs.org/
colorMode: {
preference: 'light',
fallback: 'light',
classSuffix: '',
},
webfontloader: {
google: {
families: ['Roboto:100,400,500,700', 'Roboto Mono'],
},
},
purgeCSS: {
mode: 'postcss',
enabled: isProduction,
whitelist: ['dark-mode', 'light-mode', /token$/, 'taxonomy', 'document'],
},
server: {
host: '0.0.0.0',
},
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {
extractCSS: true,
// No need for different file names,
// we are OK with same file names.
// No need to cache for eternity, under heavy traffic, it's OK
// Same file served from browser cache not too long.
filenames: {
// rel=#79
// https://github.com/renoirb/site/issues/79
app: ({ isDev, isModern }) =>
isDev
? `[name]${isModern ? '.modern' : ''}.js`
: `[contenthash:7]${isModern ? '.modern' : ''}.js`,
chunk: ({ isDev, isModern }) =>
isDev
? `[name]${isModern ? '.modern' : ''}.js`
: `[contenthash:7]${isModern ? '.modern' : ''}.js`,
css: () => '[name].css',
img: () => '[path][name].[ext]',
font: () => '[path][name].[ext]',
video: () => '[path][name].[ext]',
},
},
generate: {
dir: 'dist',
},
typescript: {},
}
// eslint-disable-next-line no-console
console.log('Nuxt Config', {
isProduction,
NODE_ENV: process.env.NODE_ENV,
IS_CI,
'router.base': main?.router?.base,
})
export default main