-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
190 lines (159 loc) · 4.32 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
import { Configuration } from '@nuxt/types';
import fg from 'fast-glob';
import settings from './app/content/settings/general.json';
import manifest from './app/content/settings/manifest.json';
const nuxtConfig: Configuration = {
/*
** Headers of the page
*/
head: {
titleTemplate: `%s ${settings.titleTemplate}`,
title: settings.title,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: settings.seoDescription },
{
hid: 'og:title',
property: 'og:title',
content: `${settings.title} ${settings.titleTemplate}`,
},
{
hid: 'og:description',
property: 'og:description',
content: settings.seoDescription,
},
{
hid: 'og:image',
property: 'og:image',
content: settings.seoMetaImage,
},
],
script: [{ src: 'https://identity.netlify.com/v1/netlify-identity-widget.js', defer: true }],
link: [
{
rel: 'preconnect',
href: 'https://d33wubrfki0l68.cloudfront.net',
},
],
},
srcDir: 'app/',
/*
** Customize the progress-bar color
*/
loading: { color: settings.loadingColor },
/*
** Global CSS
*/
css: ['@/assets/css/main.scss'],
styleResources: {
scss: ['~assets/css/_variables.scss', '~assets/css/_mixins.scss'],
},
generate: {
subFolders: false,
routes: [
...fg.sync(['./app/content/blog/**.json', './app/content/pages/**.json']).map(url => ({
route: url.replace(/^.\/app\/content(\/pages)?|.json$/gi, ''),
payload: require(url),
})),
],
},
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js modules
*/
modules: ['@nuxtjs/pwa', '@nuxtjs/style-resources', '@nuxtjs/markdownit'],
markdownit: {
preset: 'default',
injected: true,
// Convert '\n' in paragraphs into <br>
breaks: true,
// Enable HTML tags in source
html: true,
// Enable some language-neutral replacement + quotes beautification
typographer: true,
},
workbox: {
runtimeCaching: [
{
urlPattern: 'https://d33wubrfki0l68.cloudfront.net/.*',
handler: 'cacheFirst',
},
],
},
pwa: {
icon: {
iconSrc: `app/static${settings.icon}`,
},
},
manifest: {
name: manifest.name,
short_name: manifest.shortName,
description: manifest.description,
theme_color: manifest.themeColor,
background_color: manifest.backgroundColor,
lang: manifest.lang || 'en',
},
meta: {
ogTitle: false,
ogDescription: false,
},
// Serve both, the modern bundle <script type="module"> and the legacy bundle <script nomodule> scripts,
// also provide a <link rel="modulepreload"> for the modern bundle.
// Every browser that understands the module type will load the modern bundle while older browsers fall back to the legacy (transpiled) one.
...(process.env.NODE_ENV === 'production' && {
modern: 'client',
}),
buildModules: [
[
'@nuxt/typescript-build',
{
typeCheck: false,
ignoreNotFoundWarnings: true,
},
],
'@nuxtjs/eslint-module',
'@nuxtjs/tailwindcss',
],
build: {
html: {
minify: {
removeOptionalTags: false,
collapseWhitespace: true,
decodeEntities: true,
// CSS & JS are already optimised with TerserWebpack & OptimizeCSSAssetsPlugin
minifyCSS: false,
minifyJS: false,
processConditionalComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
trimCustomFragments: true,
useShortDoctype: true,
},
},
publicPath: process.env.npm_lifecycle_event === 'generate' ? '/pwa/' : '/_nuxt/',
devtools: process.env.NODE_ENV !== 'production',
optimization: {
splitChunks: {
name: true,
},
runtimeChunk: true,
},
// Split chunks
splitChunks: {
layouts: true,
pages: true,
commons: true,
},
parallel: process.env.NODE_ENV !== 'production',
extractCSS: process.env.NODE_ENV === 'production',
// Extend webpack config
extend(config, { isDev }): void {
config.devtool = isDev ? 'eval-source-map' : false;
},
},
};
export default nuxtConfig;