-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.js
162 lines (159 loc) · 4.35 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
import glob from 'glob'
import path from 'path'
import postcssImport from 'postcss-import'
import postcssNesting from 'postcss-nesting'
import postcssPresetEnv from 'postcss-preset-env'
import * as SITE_INFO from './assets/content/site/info.json'
import { COLOR_MODE_FALLBACK } from './utils/globals.js'
const dynamicContentPath = 'assets/content' // ? No prepending/appending backslashes here
const dynamicRoutes = getDynamicPaths(
{
blog: 'blog/*.json',
projects: 'projects/*.json'
},
dynamicContentPath
)
export default {
// ? The env Property: https://nuxtjs.org/api/configuration-env/
env: {
url:
process.env.NODE_ENV === 'production'
? process.env.URL || 'http://createADotEnvFileAndSetURL'
: 'http://localhost:3000',
lang: SITE_INFO.sitelang || 'en-US'
},
/*
** Headers of the page
*/
head: {
title: SITE_INFO.sitename || process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: SITE_INFO.sitedescription || process.env.npm_package_description || ''
}
],
link: [
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Karla:ital,wght@0,400;0,700;1,400&display=swap'
}
] // ? Imports the font 'Karla' and is optimized by the netlify plugin 'Subfont'
},
generate: {
routes: dynamicRoutes,
fallback: true,
subFolders: false
},
/*
** Customize the progress-bar color
*/
loading: { color: '#f3f5f4' },
/*
** Global CSS
*/
css: ['@/assets/css/tailwind.css', '@/assets/css/main.pcss'],
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js dev-modules
*/
buildModules: ['@nuxtjs/color-mode', '@nuxtjs/tailwindcss', '@nuxtjs/svg', '@nuxtjs/pwa'],
/*
** Nuxt.js modules
*/
modules: ['@nuxtjs/markdownit', 'nuxt-purgecss'],
markdownit: {
injected: true
},
/*
** Build configuration
*/
build: {
extractCSS: true,
postcss: {
plugins: {
'postcss-import': postcssImport,
tailwindcss: path.resolve(__dirname, './tailwind.config.js'),
'postcss-nesting': postcssNesting,
'postcss-preset-env': postcssPresetEnv({
stage: 1,
features: {
'nesting-rules': false
}
})
}
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {}
},
/*
** Custom additions configuration
*/
tailwindcss: {
cssPath: '~/assets/css/tailwind.css',
exposeConfig: false // enables `import { theme } from '~tailwind.config'`
},
purgeCSS: {
mode: 'postcss',
whitelist: ['dark-mode', 'light-mode', 'btn', 'icon', 'main'],
whitelistPatterns: [/^article/, /image$/]
},
colorMode: {
preference: 'system', // default value of $colorMode.preference
fallback: COLOR_MODE_FALLBACK, // fallback value if not system preference found
componentName: 'ColorScheme',
cookie: {
options: {
sameSite: 'lax'
}
}
},
pwa: {
icon: {
source: 'static/icon.png',
filename: 'icon.png'
},
manifest: { name: SITE_INFO.sitename || process.env.npm_package_name || '', lang: process.env.lang },
meta: {
name: SITE_INFO.sitename || process.env.npm_package_name || '',
lang: process.env.lang,
ogHost: process.env.URL,
ogImage: '/ogp.jpg'
}
}
}
/**
* Create an array of URLs from a list of files
* @param {*} urlFilepathTable - example below
* {
* blog: 'blog/*.json',
* projects: 'projects/*.json'
* }
*
* @return {Array} - Will return those files into urls for SSR generated .html's like
* [
* /blog/2019-08-27-incidunt-laborum-e ,
* /projects/story-test-story-1
* ]
*/
function getDynamicPaths(urlFilepathTable, cwdPath) {
console.log('Going to generate dynamicRoutes for these collection types: ', urlFilepathTable)
const dynamicPaths = [].concat(
...Object.keys(urlFilepathTable).map(url => {
const filepathGlob = urlFilepathTable[url]
return glob.sync(filepathGlob, { cwd: cwdPath }).map(filepath => {
return `/${url}/${path.basename(filepath, '.json')}`
})
})
)
console.log('Found these dynamicPaths that will be SSR generated:', dynamicPaths)
return dynamicPaths
}