-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
114 lines (112 loc) · 3.65 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
require('dotenv').config()
const { ALI_OSS_REGION, ALI_OSS_BUCKET, ALI_OSS_ASSETS_PREFIX } = process.env
let publicPath = `https://${ALI_OSS_BUCKET}.${ALI_OSS_REGION}.aliyuncs.com/${ALI_OSS_ASSETS_PREFIX || ''}`
const cdnOrigin = `https://${ALI_OSS_BUCKET}.${ALI_OSS_REGION}.aliyuncs.com`
const jsdelivr = 'https://cdn.jsdelivr.net'
if (!ALI_OSS_BUCKET || !ALI_OSS_REGION) publicPath = '/_nuxt/'
if (process.env.NODE_ENV !== 'production') publicPath = '/_nuxt/'
module.exports = {
telemetry: false,
components: true,
head: {
titleTemplate: '%s | KEEER 帐号',
title: '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'KEEER 帐号服务' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{
rel: 'stylesheet',
type: 'text/css',
href: 'https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css',
integrity: 'sha256-EZPoNbrxZm1uWJ3Dv+6E50gsinU2w1iD0QzBGr0TRgQ=',
crossorigin: 'anonymous',
},
],
htmlAttrs: { lang: 'zh-CN' },
},
render: {
csp: process.env.NODE_ENV === 'development' && !process.env.DEBUG_CSP
? false
: {
reportOnly: false,
hashAlgorithm: 'sha256',
policies: {
'default-src': [ '\'self\'', cdnOrigin, '\'report-sample\'' ],
'img-src': [ '\'self\'', 'data:', jsdelivr, `https://*.${ALI_OSS_REGION}.aliyuncs.com`, 'https://keeer.net', 'https://*.keeer.net', 'https://www.google-analytics.com', 'https://payjs.cn' ],
'script-src': [
'\'self\'', cdnOrigin, jsdelivr, 'https://www.google-analytics.com', 'https://ssl.google-analytics.com', '\'report-sample\'',
...(process.env.NODE_ENV === 'development' ? [ '\'unsafe-eval\'' ] : []),
],
'style-src': [ '\'self\'', jsdelivr, cdnOrigin, '\'unsafe-inline\'', '\'report-sample\'' ],
'font-src': [ '\'self\'', jsdelivr, cdnOrigin, '\'report-sample\'' ],
'object-src': [ '\'none\'' ],
'form-action': [ '\'self\'', '\'report-sample\'' ],
'frame-ancestors': [ '\'self\'' ],
'connect-src': [ '\'self\'', 'https://www.google-analytics.com' ],
'report-uri': [ '/csp-vio' ],
},
},
},
loading: { color: '#f5fafd' },
build: {
extractCSS: true,
optimization: {
splitChunks: {
cacheGroups: {
pages: {
name: 'pages',
test: /pages/,
},
login: {
name: 'login',
test: /login/,
priority: 5,
},
},
},
},
publicPath,
filenames: {
app: ({ isDev }) => isDev ? '[name].js' : 'main.[contenthash].js',
chunk: ({ isDev }) => isDev ? '[name].js' : '[name].[contenthash].js',
css: ({ isDev }) => isDev ? '[name].css' : '[name].[contenthash].css',
},
extend (config, { isClient }) {
if (isClient) {
config.optimization.splitChunks.cacheGroups.commons.automaticNameDelimiter = '-'
}
},
},
buildModules: [
'@nuxtjs/eslint-module',
'@nuxtjs/vuetify',
'@nuxtjs/google-analytics',
],
googleAnalytics: { id: process.env.GA_ID },
modules: [
'@nuxtjs/dotenv',
],
vuetify: {
theme: {
themes: {
light: {
primary: '#002d4d',
secondary: '#002d4d',
accent: '#002d4d',
error: '#f44336',
warning: '#f57f17',
info: '#2196f3',
success: '#4caf50',
},
},
},
defaultAssets: {
font: false,
icons: false,
},
},
}