-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.ts
115 lines (114 loc) · 2.95 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
import { resolve } from 'path'
// element-plus
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// icons
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
export default defineNuxtConfig({
devtools: {
// 本地开发启用devtools
enabled: process.env.NODE_ENV !== 'production',
},
// 配置自定义 Meta 以及 SEO选项
app: {
baseURL: '/client',
head: {
title: import.meta.env.VITE_SYSTEM_NAME,
meta: [
{
'data-n-head': 'ssr',
name: 'viewport',
content: 'width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover',
},
{ 'data-n-head': 'ssr', 'http-equiv': 'X-UA-Compatible', content: 'IE=edge,chrome=1' },
],
link: [{ rel: 'icon', href: 'favicon.ico' }],
style: [],
script: [],
noscript: [],
},
// 配置页面根节点id,默认是 _nuxt
rootId: '__SSR_APP_UI__',
},
alias: {
// 以下两项配置项是为了临时解决运行时 @nuxt/content 报错的问题
'micromark/lib/preprocess.js': 'micromark',
'micromark/lib/postprocess.js': 'micromark',
},
build: {
transpile: process.env.NODE_ENV === 'production' ? ['element-plus/es', 'fsevents'] : ['fsevents'],
},
// 打包文件夹
buildDir: import.meta.env.VITE_BUILD_DIR,
// 默认引入的css文件
css: ['element-plus/dist/index.css', '~/assets/styles/main.scss'],
imports: {
dirs: ['composables/**', 'store/**', 'components/**'],
},
plugins: ['@/plugins/element-plus', '@/plugins/authDirective'],
modules: ['unplugin-icons/nuxt', '@pinia/nuxt', '@pinia-plugin-persistedstate/nuxt', 'nuxt-lodash', '@nuxt/content'],
content: {},
// postcss相关配置
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
devServer: {
host: '0.0.0.0',
port: 2024,
},
// 项目文件在src内,默认项目文件在根目录,注意:配置此项之后,需同步更新相关资源引用路径配置
srcDir: 'src/',
runtimeConfig: {
public: {
baseURL: import.meta.env.VITE_PROXY_BASE_URL,
proxyUrl: import.meta.env.VITE_PROXY_URL,
systemName: import.meta.env.VITE_SYSTEM_NAME,
},
app: {},
},
// 开发环境代理配置
nitro: {
devProxy: {
[`${import.meta.env.VITE_PROXY_BASE_URL}`]: {
target: import.meta.env.VITE_PROXY_URL,
changeOrigin: true,
},
},
},
// vite相关配置
vite: {
plugins: [
AutoImport({
resolvers: [
ElementPlusResolver({
importStyle: false,
}),
],
}),
Components({
dts: true,
resolvers: [
ElementPlusResolver({
importStyle: false,
}),
IconsResolver({
prefix: 'icon',
customCollections: ['custom'],
}),
],
}),
Icons({
autoInstall: true,
customCollections: {
custom: FileSystemIconLoader(resolve('src/assets/icons')),
},
}),
],
},
})