1 Star 0 Fork 163

姬长修/lowflow-design

forked from 蔡晓峰/lowflow-design 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
vite.config.ts 3.25 KB
一键复制 编辑 原始数据 按行查看 历史
蔡晓峰 提交于 2024-05-07 22:57 . 重构版
import {fileURLToPath, URL} from 'node:url'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import VueDevTools from 'vite-plugin-vue-devtools'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import {viteMockServe} from "vite-plugin-mock";
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";
import Unocss from 'unocss/vite'
import {resolve} from "path";
// https://vitejs.dev/config/
export default defineConfig({
base: '/lowflow-design',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host: '0.0.0.0',
port: 3200,
open: true,
proxy: {
'/api': {
target: 'http://localhost:8084',
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/^\/api/, ''),
secure: false
}
}
},
plugins: [
vue(),
vueJsx(),
Unocss(),
VueDevTools(),
VueSetupExtend(),
viteMockServe({
mockPath: './src/mock',
localEnabled: true,
prodEnabled: true,
injectCode: ` import { setupProdMockServer } from './mockProdServer'; setupProdMockServer(); `,
}),
Components({
extensions: ['vue', 'tsx', 'md'],
globs: ['src/components/*/*.vue', 'src/components/*/*.tsx'],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/, /\.[tj]sx?$/],
resolvers: [
ElementPlusResolver({
importStyle: 'sass',
}),
],
dts: 'src/typings/components.d.ts'
}),
AutoImport({
imports: ['vue', 'vue-router'],
resolvers: [ElementPlusResolver()],
dts: 'src/typings/auto-imports.d.ts',
eslintrc: {
enabled: true,
filepath: './.eslintrc-auto-import.json'
}
}),
// svg 图标
createSvgIconsPlugin({
iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]'
}),
],
build: {
rollupOptions: {
output: {
// 打包分类
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
// 打包后的文件夹名称生成规则-->解决部分静态服务器无法正常返回_plugin-vue_export-helper文件
sanitizeFileName(name) {
const match = /^[a-z]:/i.exec(name)
const driveLetter = match ? match[0] : ''
return (
driveLetter +
// eslint-disable-next-line no-control-regex
name.substring(driveLetter.length).replace(/[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g, '')
)
}
}
}
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/jichangxiu/lowflow-design.git
git@gitee.com:jichangxiu/lowflow-design.git
jichangxiu
lowflow-design
lowflow-design
main

搜索帮助