-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
51 lines (51 loc) · 1.89 KB
/
vite.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
import { defineConfig } from 'vite';
import { fileURLToPath, URL } from 'url';
import vue from '@vitejs/plugin-vue';
import eslintPlugin from 'vite-plugin-eslint';
import Unocss from 'unocss/vite';
import { presetUno, presetAttributify } from 'unocss';
import transformerDirective from '@unocss/transformer-directives';
export default defineConfig({
plugins: [
vue(),
eslintPlugin({
include: ['src/**/*.js', 'src/**/*.vue', 'src/*.js', 'src/*.vue'],
}),
Unocss({
presets: [presetUno(), presetAttributify()],
rules: [
// custom-margin
[/^ml-(\d+)$/, ([, d]) => ({ 'margin-left': `${d}px` })],
[/^mr-(\d+)$/, ([, d]) => ({ 'margin-right': `${d}px` })],
[/^mt-(\d+)$/, ([, d]) => ({ 'margin-top': `${d}px` })],
[/^mb-(\d+)$/, ([, d]) => ({ 'margin-bottom': `${d}px` })],
[/^m-(\d+)$/, match => ({ margin: `${match[1]}px` })],
// custom-padding
[/^pb-(\d+)$/, ([, d]) => ({ 'padding-bottom': `${d}px` })],
[/^pt-(\d+)$/, ([, d]) => ({ 'padding-top': `${d}px` })],
[/^pl-(\d+)$/, ([, d]) => ({ 'padding-left': `${d}px` })],
[/^pr-(\d+)$/, ([, d]) => ({ 'padding-right': `${d}px` })],
[/^p-(\d+)$/, match => ({ padding: `${match[1]}px` })],
],
shortcuts: {
'init-btn': 'border-none cursor-pointer outline-none',
'space-between': 'flex flex-row justify-between items-center',
'space-between-nocenter': 'flex flex-row justify-between',
'flex-start': 'flex flex-row justify-start items-center',
'flex-start-nocenter': 'flex flex-row justify-start',
},
}),
],
transformers: [transformerDirective()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
server: {
host: true,
port: 8082,
https: false,
open: true, //在服务器启动时自动在浏览器中打开应用程序
},
});