配置:添加构建和工具配置文件
- 添加Vite构建配置(vite.config.ts) - 添加UnoCSS原子化CSS配置(unocss.config.ts) - 添加ESLint代码检查配置(eslint.config.js) - 添加服务接口配置(service.config.ts)
This commit is contained in:
parent
22712b4bfb
commit
f35f60648b
28
eslint.config.js
Normal file
28
eslint.config.js
Normal file
@ -0,0 +1,28 @@
|
||||
// eslint.config.js
|
||||
import antfu from '@antfu/eslint-config'
|
||||
|
||||
// https://github.com/antfu/eslint-config
|
||||
export default antfu(
|
||||
{
|
||||
ignores: [
|
||||
'doc/**/*.md', // 忽略文档目录下的Markdown文件
|
||||
],
|
||||
typescript: {
|
||||
overrides: {
|
||||
'perfectionist/sort-exports': 'off',
|
||||
'perfectionist/sort-imports': 'off',
|
||||
'ts/no-unused-expressions': ['error', { allowShortCircuit: true }],
|
||||
},
|
||||
},
|
||||
vue: {
|
||||
overrides: {
|
||||
'vue/no-unused-refs': 'off', // 暂时关闭,等待vue-lint的分支合并
|
||||
'vue/no-reserved-component-names': 'off',
|
||||
'vue/component-definition-name-casing': 'off',
|
||||
'vue/block-order': ['error', {
|
||||
order: ['template', 'script', 'style'],
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
12
service.config.ts
Normal file
12
service.config.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/** 不同请求服务的环境配置 */
|
||||
export const serviceConfig: Record<ServiceEnvType, Record<string, string>> = {
|
||||
dev: {
|
||||
url: 'http://localhost:18099',
|
||||
},
|
||||
test: {
|
||||
url: 'http://localhost:18099',
|
||||
},
|
||||
prod: {
|
||||
url: 'http://localhost:18099',
|
||||
},
|
||||
}
|
||||
17
unocss.config.ts
Normal file
17
unocss.config.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { defineConfig, presetAttributify, presetUno, transformerVariantGroup } from 'unocss'
|
||||
|
||||
// https://github.com/unocss/unocss
|
||||
|
||||
export default defineConfig({
|
||||
presets: [presetUno({ dark: 'class' }), presetAttributify()],
|
||||
shortcuts: {
|
||||
'wh-full': 'w-full h-full',
|
||||
'flex-center': 'flex justify-center items-center',
|
||||
'flex-col-center': 'flex-center flex-col',
|
||||
'flex-x-center': 'flex justify-center',
|
||||
'flex-y-center': 'flex items-center',
|
||||
},
|
||||
transformers: [
|
||||
transformerVariantGroup(),
|
||||
],
|
||||
})
|
||||
38
vite.config.ts
Normal file
38
vite.config.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { resolve } from 'node:path'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import { createVitePlugins } from './build/plugins'
|
||||
import { createViteProxy } from './build/proxy'
|
||||
import { serviceConfig } from './service.config'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
||||
const env = loadEnv(mode, __dirname, '') as ImportMetaEnv
|
||||
const envConfig = serviceConfig[mode as ServiceEnvType]
|
||||
|
||||
return {
|
||||
base: env.VITE_BASE_URL,
|
||||
plugins: createVitePlugins(env),
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
proxy:
|
||||
env.VITE_HTTP_PROXY === 'Y' ? createViteProxy(envConfig) : undefined,
|
||||
},
|
||||
build: {
|
||||
target: 'esnext',
|
||||
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
api: 'modern',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user