-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
83 lines (80 loc) · 2.16 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
require('dotenv').config();
const isProd = process.env.NODE_ENV === 'production';
const STATIC_URL = isProd
? `https://${process.env.CDN_DOMAIN}`
: `http://localhost:${parseInt(process.env.PORT, 10) || 8000}`
module.exports = {
head: {
title: "Serverless CNode:Node.js专业中文社区",
meta: [
{ charset: "utf-8" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{
hid: "description",
name: "description",
content: "基于 Serverless 部署和Nuxt (服务器端渲染 SSR) 构建 CNode 社区",
},
],
link: [{ rel: "icon", type: "image/x-icon", href: `${STATIC_URL}/favicon.ico` }],
},
css: [
"~/assets/prettify/prettify.css",
{ src: "~/assets/theme/index.scss", lang: "scss" },
],
loading: { color: "#3B8070" },
env: {
STATIC_URL: STATIC_URL,
},
build: {
extend(config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: "pre",
test: /\.(js|vue)$/,
loader: "eslint-loader",
exclude: /(node_modules)/,
});
}
// ********* Notice ***********
// ********* If prod and set CDN_DOMAIN, setup publicPath to it
if (!isDev && process.env.CDN_DOMAIN) {
config.output.publicPath = `https://${process.env.CDN_DOMAIN}/`
}
},
},
modules: ["@nuxtjs/axios", "@nuxtjs/toast"],
toast: {
position: "top-center",
duration: 800,
},
axios: {
baseURL: 'https://cnodejs.org/api/v1',
},
buildModules: [
"@nuxtjs/style-resources",
'@nuxtjs/pwa',
],
styleResources: {
scss: [
"sass-bem/_bem.scss",
"~/assets/theme/common/var.scss",
"~/assets/theme/common/utils.scss",
"~/assets/theme/common/mixins.scss",
],
},
pwa: {
// TODO: can not work with custom express server with icon?
icon: false,
manifest: {
name: "Serverless CNode",
lang: "zh-CN"
}
},
plugins: [
"~/plugins/axios",
"~/plugins/filters.js",
"~/plugins/packages.js",
{ src: "~/assets/prettify/prettify.js", ssr: false },
{ src: "~/plugins/localStorage.js", ssr: false },
],
};