1 Star 0 Fork 121

646962105/OpenDataV

forked from 星星在线/OpenDataV 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
import type { UserConfigExport, ConfigEnv, ProxyOptions } from 'vite'
import { loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import MarkDownPlugin from 'vite-plugin-vue-markdown'
import { viteMockServe } from 'vite-plugin-mock'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default ({ mode, command }: ConfigEnv): UserConfigExport => {
const { VITE_APP_PORT, VITE_APP_PROXY, VITE_MOCK } = loadEnv(mode, process.cwd())
const createProxy = (propxyList) => {
const ret = {} as Record<string, ProxyOptions>
for (const [prefix, target] of propxyList) {
ret[prefix] = {
target: target,
changeOrigin: true,
rewrite: (path) => path.replace(new RegExp(`^${prefix}`), '')
}
}
return ret
}
return {
plugins: [
vue({
include: [/\.vue$/, /\.md$/] // <--
}),
vueJsx(),
viteMockServe({
mockPath: 'mock',
supportTs: true, //如果使用 js发开,则需要配置 supportTs 为 false
logger: true,
localEnabled: command === 'serve',
prodEnabled: VITE_MOCK === 'true',
injectCode: `
import { setupProdMockServer } from '../mock/mockProdServer';
setupProdMockServer();
`
}),
MarkDownPlugin({
markdownItSetup(md) {
md.use(require('./build/toc.js'))
}
})
],
base: './',
resolve: {
alias: {
// 路径别名
'@': resolve(__dirname, 'src')
},
// 使用路径别名时想要省略的后缀名,官方不建议将.vue文件省略后缀
extensions: ['.js', '.ts']
},
server: {
// 是否开启 https
https: false,
port: Number(VITE_APP_PORT),
host: '0.0.0.0',
open: false,
proxy: createProxy(JSON.parse(VITE_APP_PROXY)),
fs: {
allow: ['..'],
strict: false
},
cors: true
},
build: {
target: 'es2015',
chunkSizeWarningLimit: 1500,
terserOptions: {
compress: {
keep_infinity: true,
// Used to delete console in production environment
drop_console: true
}
}
},
css: {
preprocessorOptions: {
less: {
modifyVars: {
hack: `true; @import (reference) "${resolve('src/css/index.less')}";`
},
javascriptEnabled: true
}
},
modules: {
localsConvention: 'camelCase'
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/xiaoning333/OpenDataV.git
git@gitee.com:xiaoning333/OpenDataV.git
xiaoning333
OpenDataV
OpenDataV
main

搜索帮助