forked from rymcu/nebula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
107 lines (105 loc) · 2.5 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
import appConfig from './config/app.config'
import apiConfig from './config/api.config'
import {isDevMode} from './environment'
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
export default {
/*
** Nuxt rendering mode
** See https://nuxtjs.org/api/configuration-mode
*/
ssr: true,
/*
** Render configuration
*/
render: {
csp: false
},
modern: true,
dev: isDevMode,
env: {
BASE: apiConfig.BASE,
HOST_URL: apiConfig.SOCKET
},
cache: {
max: 100,
maxAge: 1000 * 60 * 15
},
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
title: appConfig.meta.title,
meta: [
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{hid: 'keywords', name: 'keywords', content: appConfig.meta.keywords},
{hid: 'description', name: 'description', content: appConfig.meta.description}
],
link: [
{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
]
},
/*
** Global CSS
*/
css: [
'element-ui/lib/theme-chalk/index.css',
'@fortawesome/fontawesome-svg-core/styles.css'
],
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: [
{src: '~/plugins/avataaars/generator/generateAvatar'},
{src: '~/plugins/extend'},
{src: '~/plugins/axios'},
{src: '~/plugins/element-ui'},
{src: '~/plugins/vditor', ssr: false},
{src: '~/plugins/fontawesome'},
// {src: '~/plugins/vue-cropper', ssr: false}
],
/*
** Nuxt.js dev-modules
*/
buildModules: [],
/*
** Nuxt.js modules
*/
modules: [
'~/io',
'@nuxtjs/axios',
'@nuxtjs/proxy',
'js-cookie',
'cookieparser'
],
axios: {
proxy: true // 开启proxy
},
proxy: [ //proxy配置
['/api', {
target: apiConfig.BASE, //api请求路径
pathRewrite: {'^/api': isDevMode ? '/api/v1' : '/api'} //重定向请求路径,防止路由、api路径的冲突
}]
],
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {
transpile: [/^element-ui/],
optimization: {
splitChunks: {
minSize: 10000,
maxSize: 250000
}
},
extend(config, ctx) {
config.plugins.unshift(new LodashModuleReplacementPlugin())
// rules[2].use[0] is babel-loader
config.module.rules.push({ test: /\.txt$/, use: 'raw-loader' })
config.module.rules[2].use[0].options.plugins = ['lodash']
}
}
}