-
Notifications
You must be signed in to change notification settings - Fork 1
/
nuxt.config.js
187 lines (164 loc) · 4.23 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
const glob = require('glob');
const path = require('path');
const pkg = require('./package');
/**
* Create an array of URLs from a list of files
* @param {*} urlFilepathTable
*/
function getDynamicPaths(urlFilepathTable) {
return [].concat(
...Object.keys(urlFilepathTable).map(url => {
const filepathGlob = urlFilepathTable[url];
return glob
.sync(filepathGlob, { cwd: 'content' })
.map(filepath => `${url}/${path.basename(filepath, '.json')}`);
})
);
}
// Enhance Nuxt's generate process by gathering all content files from Netifly CMS
// automatically and match it to the path of your Nuxt routes.
// The Nuxt routes are generate by Nuxt automatically based on the pages folder.
// const dynamicRoutes = getDynamicPaths({
// // '/movies': 'movies/*.json'
// // '/blog': 'blog/posts/*.json',
// // '/page': 'page/posts/*.json',
// // '/category': 'categories/posts/*.json',
// // '/tagged': 'tags/posts/*.json'
// });
console.log('Dynamic Routes:');
// console.log({ dynamicRoutes });
console.log(`process.env.movieDbApiKey: ${process.env.movieDbApiKey}`);
/**
* Routes used by Nuxt generate and Sitemap
* @type {string[]}
*/
const routes = [
'/',
// ...dynamicRoutes
];
/**
* NUXTJS Config
*/
module.exports = {
env: {
movieDbApiKey: process.env.movieDbApiKey || require('./.themoviedb.js').key
},
mode: 'universal',
// modern: 'client',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description },
{ name: 'msapplication-TileColor', content: '#da532c' },
{ name: 'theme-color', content: '#ffffff' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ 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: '#5bbad5' },
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css?family=Zilla+Slab:400,700'
}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'~/assets/sass/app.scss'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
{ src: '~/plugins/vuex-persistedstate.js', ssr: true },
{ src: '~/plugins/gsap', ssr: false },
{ src: '~/plugins/vue-lazy-load', ssr: false }
],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/axios',
// '@nuxtjs/sitemap',
['nuxt-svg-sprite-module', {
directory: '/assets/icons',
options: {
// Configuration options:
// https://github.com/jkphl/svg-sprite#configuration-basics
}
}]
],
/*
** Route config for pre-rendering
*/
generate: {
// routes: dynamicRoutes
routes: routes
},
terser: {
sourceMap: true
},
/*
** Build configuration
*/
build: {
extractCSS: true,
babel: {
presets({ isServer }) {
return [
[
require.resolve('@nuxt/babel-preset-app'),
// require.resolve('@nuxt/babel-preset-app-edge'), // For nuxt-edge users
{
targets: isServer ? { node: '10' } : { ie: '11' },
corejs: { version: 2 }
}
]
];
}
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
});
}
}
},
axios: {
debug: false,
// https: true
},
sitemap: {
path: '/sitemap.xml',
// hostname: 'https://www.xxxxx.com',
cacheTime: 1000 * 60 * 15,
gzip: true,
generate: true, // Enable me when using nuxt generate
exclude: [
'/admin/**'
],
routes: routes
}
};