-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuxt.config.js
More file actions
45 lines (44 loc) · 1.44 KB
/
nuxt.config.js
File metadata and controls
45 lines (44 loc) · 1.44 KB
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
const modifyHtml = (html) => {
// Add amp-custom tag to added CSS
html = html.replace(/<style data-vue-ssr/g, '<style amp-custom data-vue-ssr')
// Remove every script tag from generated HTML
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '')
// Add AMP script before </head>
const ampScript = '<script async src="https://cdn.ampproject.org/v0.js"></script>'
html = html.replace('</head>', ampScript + '</head>')
return html
}
export default {
router: {
base: '/'
},
head: {
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width,minimum-scale=1' }
],
link: [
{ rel: 'canonical', href: '/' },
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Roboto' },
{ rel: 'stylesheet', href: 'https://cdn.rawgit.com/Chalarangelo/mini.css/v3.0.1/dist/mini-default.min.css' }
]
},
loading: false, // Disable loading bar since AMP will not generate a dynamic page
render: {
// Disable resourceHints since we don't load any scripts for AMP
resourceHints: false
},
hooks: {
// This hook is called before generatic static html files for SPA mode
'generate:page': (page) => {
page.html = modifyHtml(page.html)
},
// This hook is called before rendering the html to the browser
'render:route': (url, page, { req, res }) => {
page.html = modifyHtml(page.html)
}
},
generate: {
dir: 'docs'
}
}