-
Notifications
You must be signed in to change notification settings - Fork 143
/
nuxt.config.js
148 lines (141 loc) · 3.28 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
import config from './configs/config'
if (process.env.NODE_ENV === 'production') {
console.log('Deploying to ...', process.env.NUXT_ENV_DEPLOY)
}
/**
* @type {import('@nuxt/types').NuxtConfig}
*/
export default {
ssr: true,
// TODO static target will generate lot's of static js files. Not sure why
// target: 'static',
router: {
mode: 'history',
base: config.routerBase,
scrollBehavior(to) {
if (to.hash) {
const id = to.hash.substr(1)
const el =
document.getElementById(decodeURIComponent(id)) ||
document.getElementById(id)
if (el) {
el.scrollIntoView &&
el.scrollIntoView({
behavior: 'smooth'
})
}
} else {
document.getElementsByClassName('page-main')[0].scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
})
}
}
},
/*
** Headers of the page
*/
head: {},
tailwindcss: {},
/*
** Customize the progress-bar color
*/
loading: {
color: '#F72C5B',
continuous: true
},
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js dev-modules
*/
buildModules: ['@nuxt/typescript-build', '@nuxtjs/tailwindcss'],
/*
** Nuxt.js modules
*/
modules: [
[
'nuxt-i18n',
{
locales: ['en', 'zh'],
strategy: 'prefix',
defaultLocale: 'en',
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
onlyOnRoot: true
},
vueI18n: {
fallbackLocale: 'en',
messages: {
en: {
inThisPage: 'In This Page',
searchHandbook: 'Search Handbook',
contributorsWithThisDocument: 'Contributors',
editInThisDocumentTip: 'Edit this Document',
editInGithub: 'Edit this page on GitHub'
},
zh: {
inThisPage: '本页目录',
searchHandbook: '搜索手册',
contributorsWithThisDocument: '本文贡献者',
editInThisDocumentTip: '编辑本文',
editInGithub: '在 GitHub 上编辑本页'
}
}
}
}
]
],
/*
** Build configuration
*/
build: {
postcss: {
plugins: {
'postcss-nested': {},
'postcss-import': {}
}
},
extractCSS: {
// allChunks: true
},
/*
** You can extend webpack config here
*/
extend(config, ctx) {
config.resolve.alias['vue'] = 'vue/dist/vue.common'
config.module.rules.push({
test: /\.md$/,
use: ['raw-loader']
})
//github.com/nuxt/nuxt.js/issues/4736#issuecomment-453429870
https: config.module.rules.push({
test: /\.ya?ml$/,
use: 'js-yaml-loader'
})
// if (ctx.isDev && ctx.isClient) {
// config.module.rules.push({
// enforce: 'pre',
// test: /\.(js|vue)$/,
// loader: 'eslint-loader',
// exclude: /(node_modules)/,
// options: { fix: true }
// })
// }
},
filenames: {
chunk: ({ isDev }) => (isDev ? '[name].js' : 'js/[contenthash].js')
}
},
generate: {
crawler: true
}
}