-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
130 lines (125 loc) · 3.93 KB
/
nuxt.config.ts
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
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import AutoImport from 'unplugin-auto-import/vite'
import Components from "unplugin-vue-components/vite";
const lifecycle = process.env.npm_lifecycle_event;
const { ENV } = process.env
const now = new Date();
const VERSION = [now.getMonth() + 1, now.getDate(), now.getHours(), now.getMinutes()].join(".")
console.log('ENV=', ENV)
console.log('VERSION=', VERSION)
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
modules: [
// '@nuxtjs/axios',
"@pinia/nuxt",
],
buildModules: [
],
hooks: {
// 去掉多余的window.__NUXT__内容
'vue-renderer:ssr:context'(context) {
if (context?.nuxt?.error?.statusCode === 200) {
const routePath = JSON.stringify(context.nuxt.routePath);
context.nuxt = { serverRendered: true, routePath };
}
}
},
head: {
"htmlAttrs": {lang: 'zh-CN'},
"meta": [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }
],
"link": [
// { rel: 'stylesheet', href: 'https://awesome-lib.css' }
],
"style": [
// { children: ':root { color: red }', type: 'text/css' }
],
"script": [],
"noscript": [
{ children: 'Javascript is required' }
],
"charset": "utf-8",
},
css: [
'@/assets/css/base.less',
// 'element-plus/theme-chalk/base.css',
'element-plus/dist/index.css'
],
loading: { color: '#3B8070' },
vite: {
define: {
__ENV__: `'${ENV}'`,
__VERSION__: `'${VERSION}'`,
__API_URL__: `'https://api.mliveplus.com'`,
},
plugins: [
AutoImport({
resolvers: [ElementPlusResolver({ ssr: true })]
}),
Components({
dts: true,
resolvers: [ElementPlusResolver({ ssr: true })]
}),
],
server: {
proxy: {
'/proxy': {
// target: "https://test3_api.sun8tv.com",
// target: "https://test2-api.sun8tv.com",
// target: "https://test1-api.sun8tv.com",
// target: "https://uat-api.sun8tv.com",
target: "https://api.mliveplus.com",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/proxy/, '')
},
}
},
},
build: {
extractCSS: true,
transpile: [
...(lifecycle === 'build' || lifecycle === 'generate' ? ['element-plus'] : []), // 'element-plus/es',
],
babel: {
plugins: [
// [
// 'import',
// {
// libraryName: 'element-plus',
// libraryDirectory: 'es',
// // 选择子目录 例如 es 表示 ant-design-vue/es/component
// // lib 表示 ant-design-vue/lib/component
// style: true
// // 默认不使用该选项,即不导入样式 , 注意 ant-design-vue 使用 js 文件引入样式
// // true 表示 import 'ant-design-vue/es/component/style'
// // 'css' 表示 import 'ant-design-vue/es/component/style/css'
// }
// ]
]
},
},
components: {
"dirs": [
{
"path": "~/components/global",
"global": true
},
"~/components"
]
},
extensions: [
".js",
".jsx",
".mjs",
".ts",
".vue"
],
typescript: {
shim: true,
strict: false,
typeCheck: true
},
webpack: {},
devtools: true,
})