-
Notifications
You must be signed in to change notification settings - Fork 3
/
nuxt.config.ts
143 lines (136 loc) · 3.35 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
131
132
133
134
135
136
137
138
139
140
141
142
143
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'url'
import { defineNuxtConfig } from 'nuxt'
import presetIcons from '@unocss/preset-icons'
import VueI18nVitePlugin from '@intlify/unplugin-vue-i18n/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
const lifecycle = process.env.npm_lifecycle_event
const isProd = process.env.NODE_ENV === 'production'
export default defineNuxtConfig({
// default meta
meta: {
title: 'Element Plus + Nuxt 3',
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
hid: 'description',
name: 'description',
content: 'ElementPlus + Nuxt3',
},
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
// ...
autoImports: {
dirs: [
// Scan composables from nested directories
'composables/**',
],
},
// auto import components
components: true,
// vueuse
vueuse: {
ssrHandlers: true,
},
modules: [
'@vueuse/nuxt',
'@unocss/nuxt',
'@pinia/nuxt',
'@nuxtjs/color-mode',
'@nuxtjs/tailwindcss',
],
// build
build: {
transpile: [
// https://github.com/element-plus/element-plus-nuxt-starter/blob/44644788ee0d2a2580769769f9885b5cd9f7c0ab/nuxt.config.ts#L27
...(lifecycle === 'build' || lifecycle === 'generate'
? ['element-plus']
: []),
],
},
experimental: {
reactivityTransform: true,
viteNode: false,
},
unocss: {
uno: false,
preflight: false,
icons: true,
presets: [
presetIcons({
scale: 1.2,
extraProperties: {
display: 'inline-block',
},
}),
],
// outside html element need to include here
safelist: ['i-twemoji-flag-us-outlying-islands', 'i-twemoji-flag-china'],
},
colorMode: {
classSuffix: '',
fallback: 'light',
storageKey: 'color-mode',
},
// css
css: [
'assets/scss/element/dark.scss',
],
tailwindcss: {
cssPath: 'assets/tailwind.css',
configPath: 'tailwind.config.js',
injectPosition: {
// 'low-priority' will have lower priority than Tailwind stylesheet,
// while 'high-priorty' will override it
after: 'assets/scss/element/dark.scss',
},
viewer: false,
},
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: isProd ? '@use "assets/scss/element/index" as *;' : '@use "assets/scss/element/devOnly" as *;',
},
},
},
// Windows hot fix
server: {
watch: {
usePolling: true,
},
},
resolve: {
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js',
},
},
plugins: isProd
? [
ElementPlus({
useSource: true,
}),
Components({
dts: false,
resolvers: [
IconsResolver(),
],
}),
VueI18nVitePlugin({
include: [
resolve(dirname(fileURLToPath(import.meta.url)), './locales/*.json'),
],
}),
]
: [
VueI18nVitePlugin({
include: [
resolve(dirname(fileURLToPath(import.meta.url)), './locales/*.json'),
],
}),
],
},
})