-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
211 lines (202 loc) · 5.69 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
import fs from 'fs'
import path from 'path'
// Modes for frontmatter-markdown-loader
import Mode from 'frontmatter-markdown-loader/mode'
// Load routes for dynamic content
import routes from './contents/routes'
// Import configuration
import markdown from './config/markdown'
import minify from './config/minify'
// Open Graph
import { openGraphTags } from './config/opengraph'
// Load primary color from sass
const [, primaryColor] = fs
.readFileSync(path.join(__dirname, 'assets', 'scss', '_variables.scss'), {
encoding: 'utf8'
})
.match(/\$color__primary:\s*([^;]+);/)
export default {
target: 'static',
// Content of page head
head: {
title: 'Novit ai',
titleTemplate: '%s • Novit.ai',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'Novit ai, Edge ai for the next generation of AI, with a focus on machine learning and deep learning. We are a team of AI experts, with a passion for AI.'
},
{ name: 'msapplication-TileColor', content: '#3355ff' },
{ hid: 'theme-color', name: 'theme-color', content: '#3355ff' },
...openGraphTags
],
link: [
{ rel: 'preconnect', href: 'https://www.google-analytics.com' },
{ rel: 'preconnect', href: 'https://cdn.jsdelivr.net' },
{ rel: 'dns-prefetch', href: 'https://www.google-analytics.com' },
{ rel: 'dns-prefetch', href: 'https://cdn.jsdelivr.net' },
{
rel: 'apple-touch-icon',
sizes: '180x180',
href: '/apple-touch-icon.png'
},
{
rel: 'icon',
type: 'image/png',
sizes: '32x32',
href: '/favicon-32x32.png'
},
{
rel: 'icon',
type: 'image/png',
sizes: '16x16',
href: '/favicon-16x16.png'
},
{ rel: 'manifest', href: '/site.webmanifest' },
{ rel: 'mask-icon', href: '/safari-pinned-tab.svg', color: '#3355ff' }
],
noscript: [
{
innerHTML:
'<style>.theme-toggle,.lazy>picture::after,.lazy>picture>img{display:none;}</style>'
}
],
__dangerouslyDisableSanitizers: ['noscript']
},
// Loading bar
loading: {
color: primaryColor,
duration: 3000
},
// Global CSS
css: ['~/assets/scss/default.scss'],
// Plugins to load before mounting the app
plugins: [
'~/plugins/components.js',
'~/plugins/dynamic-content.client.js',
'~/plugins/dynamic-content.server.js',
'~/plugins/lazy-images.client.js',
'~/plugins/markdown.client.js',
'~/plugins/tabbing.client.js'
],
// Nuxt.js build modules
buildModules: [
'@nuxtjs/eslint-module',
'@nuxtjs/stylelint-module',
'@nuxtjs/style-resources',
'@nuxtjs/google-analytics',
'@nuxtjs/pwa'
],
// Nuxt.js modules
modules: ['@nuxtjs/recaptcha', '@nuxtjs/sitemap'],
// Instead of importing into every component
styleResources: {
scss: [
'~/assets/scss/_variables.scss',
'~/assets/scss/_mixins.scss',
'~/assets/scss/_typography.scss'
]
},
// Google Analytics configuration
googleAnalytics: {
id: 'UA-115006226-1'
},
recaptcha: {
hideBadge: false,
siteKey: "XXXXXXXXXXXXXXXXXXX",
size: 'invisible',
version: 2
},
// Nuxt.js PWA configuration
pwa: {
icon: false,
meta: false,
manifest: false
},
// Generate sitemap
sitemap: {
gzip: true,
hostname: 'https://novit.ai',
routes
},
// Generate dynamic routes and 404 fallback
generate: {
fallback: true,
routes: [...routes, '/meta/', ...routes.map((route) => `/meta${route}`)]
},
// Add trailing slashes to match Netlify
router: {
trailingSlash: true
},
// Renderer options for preloading
render: {
bundleRenderer: {
shouldPreload: (file, type) => {
// Preload woff2 fonts
if (type === 'font') return /\.woff2$/.test(file)
return ['script', 'style'].includes(type)
}
}
},
// Build configuration
build: {
filenames: {
app: ({ isDev }) => (isDev ? '[name].js' : '[contenthash:7].js'),
chunk: ({ isDev }) => (isDev ? '[name].js' : '[contenthash:7].js'),
css: ({ isDev }) => (isDev ? '[name].css' : '[contenthash:7].css'),
img: ({ isDev }) =>
isDev ? '[path][name].[ext]' : 'img/[contenthash:7].[ext]',
font: ({ isDev }) =>
isDev ? '[path][name].[ext]' : 'fonts/[contenthash:7].[ext]',
video: ({ isDev }) =>
isDev ? '[path][name].[ext]' : 'videos/[contenthash:7].[ext]'
},
html: {
minify
},
postcss: null,
extend(config, { isClient, loaders: { vue } }) {
// Make sure Vue knows about lazy loaded images
if (isClient) {
vue.transformAssetUrls.img = ['data-src', 'src']
vue.transformAssetUrls.source = ['data-srcset', 'srcset']
}
// Resolve path to material design icons
config.resolve.alias.icons = path.resolve(
__dirname,
'node_modules/vue-material-design-icons'
)
// Replace default image loaders with custom loader
config.module.rules.forEach((rule) => {
if (rule.test.test('.png')) {
rule.use = [
{
loader: path.resolve(__dirname, 'loaders', 'sharp'),
options: {
quality: 50
}
}
]
}
})
// Markdown loader
config.module.rules.unshift({
test: /\.md$/,
loader: 'frontmatter-markdown-loader',
options: {
mode: [Mode.HTML, Mode.BODY, Mode.VUE_RENDER_FUNCTIONS],
vue: {
root: 'markdown'
},
markdown
}
})
}
}
}