-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
119 lines (118 loc) · 3.19 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
import sitemapConfig from './config/sitemap-config'
import feedConfig from './config/feed-config'
import defaultConfig from './config/default-config'
// noinspection JSAnnotator
export default {
/*
** Headers of the page
*/
head: {
title: defaultConfig.meta_title,
titleTemplate: '%s - MerryCodes',
meta: [
{ charset: 'utf-8' },
{ 'http-equiv': 'cleartype', content: 'on' },
{ 'http-equiv': 'Cache-Control' },
{
name: 'viewport',
content: 'width=device-width, initial-scale=1, user-scalable=no'
},
{
hid: 'description',
name: 'description',
content: defaultConfig.meta_description
},
{
hid: 'keywords',
name: 'keywords',
content: defaultConfig.meta_keywords
},
{ hid: 'author', name: 'author', content: defaultConfig.meta_author },
{
hid: 'google-site-verification',
name: 'google-site-verification',
content: defaultConfig.google_site_verification
},
{
hid: 'baidu-site-verification',
name: 'baidu-site-verification',
content: defaultConfig.baidu_site_verification
}
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'stylesheet',
type: 'text/css',
href: 'https://fonts.font.im/css?family=Roboto|Source+Code+Pro'
}
],
script: [{ type: 'text/javascript', src: '/js/swiftype.js' }],
noscript: [{ innerHTML: 'This website requires JavaScript.' }]
},
/*
** Global CSS
*/
css: [
{ src: '~assets/css/main.css' },
{ src: '~assets/css/normalize.css' },
{ src: '~assets/css/style.css' },
{ src: '~assets/css/icon.css' },
'gitalk/dist/gitalk.css',
'highlight.js/styles/atom-one-dark.css'
],
modules: ['@nuxtjs/sitemap', '@nuxtjs/feed'],
sitemap: sitemapConfig.config,
feed: feedConfig.config,
plugins: [
{ src: '~plugins/highlight.js', mode: 'client' },
{ src: '~plugins/clickoutside.js', mode: 'client' },
{ src: '~plugins/ga.js', mode: 'client' },
{ src: '~plugins/filters.js' },
{ src: '~plugins/global.js' },
{ src: '~plugins/tools.js' },
{ src: '~plugins/loading.js' }
],
router: {
linkActiveClass: 'active',
// nuxt 的bug,scrollToTop不生效,要重写scrollBehavior方法
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
let position = {}
if (to.matched.length < 2) {
position = { x: 0, y: 0 }
} else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
position = { x: 0, y: 0 }
}
if (to.hash) {
position = { selector: to.hash }
}
return position
}
}
},
env: {
NODE_ENV: process.env.NODE_ENV
},
/*
** Build configuration
*/
build: {
extractCSS: true,
/*
** Run ESLint on save
*/
extend(config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
}